Compare commits

...

125 Commits

Author SHA1 Message Date
Gabor Kiss-Vamosi
6fb4235c66 prepare to release v7.7.0 2020-10-20 13:32:57 +02:00
Gabor Kiss-Vamosi
64c68ec25b release.py: add lv_sim_emscripten 2020-10-20 13:27:14 +02:00
Gabor Kiss-Vamosi
62a21e912c Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-10-19 12:33:42 +02:00
Gabor Kiss-Vamosi
df49f8656d fix image transformation
Fixes: #1854
2020-10-19 12:33:34 +02:00
Themba Dube
3d4284b02c stm32: use DSB to ensure GPU clock gets enabled 2020-10-18 12:32:22 -04:00
Gabor Kiss-Vamosi
4ca5d4e86d Update ROADMAP.md 2020-10-16 13:12:46 +02:00
Gabor Kiss-Vamosi
55d78e1f92 Update ROADMAP.md 2020-10-16 13:06:21 +02:00
Gabor Kiss-Vamosi
cf8e40fcbe Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-10-16 11:27:35 +02:00
Gabor Kiss-Vamosi
8d9c0bd9b2 fix define_set to check define name end too 2020-10-16 11:27:24 +02:00
Gabor Kiss-Vamosi
8c0ab944af Update ROADMAP.md 2020-10-15 15:21:55 +02:00
Gabor Kiss-Vamosi
79433deeb8 Update ROADMAP.md 2020-10-13 12:55:43 +02:00
Gabor Kiss-Vamosi
ddb4ae8685 fix lv_win_clean() 2020-10-13 11:53:03 +02:00
Gabor Kiss-Vamosi
489f426b27 fix rectangle border drawing with large width 2020-10-12 15:48:43 +02:00
Gabor Kiss-Vamosi
b1b233d249 fix warning 2020-10-12 13:15:48 +02:00
Gabor Kiss-Vamosi
c4f8959e65 remove version control text
Fixes #1846
2020-10-12 12:58:04 +02:00
Gabor Kiss-Vamosi
68629c725a add missing fonts
fixes: #1845
2020-10-12 12:43:51 +02:00
Gabor Kiss-Vamosi
20363b09e6 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-10-12 12:09:08 +02:00
Gabor Kiss-Vamosi
4d620d3771 fix dropdown selection with RTL basedirection
Related to: #1842
2020-10-12 12:08:49 +02:00
Sergei Kolotovchenkov
e1f222d04f Improve compatibility with C++14 (#1843) 2020-10-09 09:11:34 -04:00
Gabor Kiss-Vamosi
56c4cab228 skip objects in groups if they are in disabled state 2020-10-09 10:34:02 +02:00
Gabor Kiss-Vamosi
5d91c24723 support RTL in pretty layout (draw columns right to left)
Related to #1833
2020-10-08 15:18:30 +02:00
embeddedt
6e48cde2f1 Fix #1837: remove last designated initializer in lv_color.h 2020-10-08 08:30:29 -04:00
robekras
9ec4b61417 Fix #1798: Use AHB3 enable register for STM32H7 (#1840) 2020-10-07 14:17:38 -04:00
Gabor Kiss-Vamosi
6c426aa855 fix warnings 2020-10-07 14:03:06 +02:00
Gabor Kiss-Vamosi
c804fadf40 remove the internal usage of LV_HOR/VER_RES_MAX 2020-10-07 13:55:06 +02:00
Gabor Kiss-Vamosi
1ee9c13a1d revert debug changes in material theme 2020-10-07 13:48:31 +02:00
Gabor Kiss-Vamosi
0266244c58 support RTL in table (draw columns right to left)
Related to #1833
2020-10-07 13:47:49 +02:00
Gabor Kiss-Vamosi
f1a198bd93 fix imgbtn state change 2020-10-07 12:44:54 +02:00
Gabor Kiss-Vamosi
1d50bc962d theme update to support text selection background
Fixes #1820
2020-10-07 12:23:24 +02:00
Gabor Kiss-Vamosi
fff3a00de2 fix lv_disp_get_inactive_time if the disp==NULL
Fixes #1836
2020-10-06 11:25:37 +02:00
Gabor Kiss-Vamosi
faf50714a1 update release script 2020-10-06 11:23:40 +02:00
Gabor Kiss-Vamosi
e41bc28817 Merge branch 'master' into dev 2020-10-06 09:33:59 +02:00
Gabor Kiss-Vamosi
8b6bb63795 prepare to release v7.6.1 2020-10-06 09:30:37 +02:00
Gabor Kiss-Vamosi
0de2cc9a8e fix conflicts 2020-10-06 09:30:00 +02:00
Gabor Kiss-Vamosi
3d8a19a0ca fix version number 2020-10-06 09:29:13 +02:00
Gabor Kiss-Vamosi
bc626dc9d0 update CHANGELOG 2020-10-06 08:59:07 +02:00
github-actions[bot]
38a9426135 Merge 6b24c949f1 into dev 2020-10-05 18:46:45 +00:00
Gabor Kiss-Vamosi
6b24c949f1 fix lv_img offset usage
Fixes: https://forum.lvgl.io/t/problem-with-lv-img-set-offset-y-in-ver-7/3330
2020-10-05 20:46:09 +02:00
github-actions[bot]
44709caf6f Merge e557b0fbac into dev 2020-10-05 12:31:49 +00:00
embeddedt
e557b0fbac Only check __STDC_VERSION__ if __cplusplus is not defined 2020-10-05 08:31:20 -04:00
github-actions[bot]
b124f4d7e0 Merge 3dabec4cae into dev 2020-10-05 08:53:33 +00:00
Amir Gonnen
3dabec4cae Run test on dev branch as well (#1835) 2020-10-05 10:53:02 +02:00
github-actions[bot]
4092c71a45 Merge 78ecdd1f1d into dev 2020-10-05 07:44:20 +00:00
Gabor Kiss-Vamosi
78ecdd1f1d Update ROADMAP.md 2020-10-05 09:43:52 +02:00
Gabor Kiss-Vamosi
4c2c1dd8bd fix conflicts 2020-10-05 09:42:59 +02:00
Gabor Kiss-Vamosi
e33e1df4af Merge branch 'feature/vg-lite-support-dev-7-7' of https://github.com/NXPmicro/lvgl into NXPmicro-feature/vg-lite-support-dev-7-7 2020-10-05 09:23:53 +02:00
github-actions[bot]
4c7a2ae0b7 Merge 96478a0c3e into dev 2020-10-03 12:38:29 +00:00
C47D
96478a0c3e lv_conf_internal: Check for LV_CONF_INCLUDE_SIMPLE before defining it. 2020-10-03 08:37:49 -04:00
github-actions[bot]
61437e793a Merge 86ddaf90a7 into dev 2020-10-02 19:46:11 +00:00
Gabor Kiss-Vamosi
86ddaf90a7 material theme: do not set the text font to allow easy global font change 2020-10-02 21:45:32 +02:00
Ali Rostami
8394d92fac Cursor (#1789)
* update lv_obj_refresh_style describtion.

* cursor added.

* refresh chart after setting the cursor

* add new direction and a bug fixed.

* fixed the wrong changes for header file.

* rename lv_cursor_direction_t enum members.

* add lv_chart_get_x_from_index and lv_chart_get_y_from_index

* lv_chart_get_x_from_index supports column chart type too.

* fix the error of no lv_coord_t value return.

* fix a bug based on the coord is with respect to the series area.

* make get_series_area function global.

* fix the name of get_series_area function.

* add the description of the added functions.

* chart cursor minor fixes

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2020-10-02 13:59:05 +02:00
jozba
fc2206105b Fixed include paths (#1823)
Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>
2020-10-02 13:12:41 +02:00
jozba
b049b7e1f6 Bugfix/mgg 562 lvgl pxp symbol prefix missing include path update blit limit (#1830)
* PXP: Updated area threshold, fixed symbol names, minor fixes

- Area threshold of 1 left from debugging, changed to 32 for performance
reasons.
- Fixed naming convention of symbols (prefix LV_GPU_)
- Fixed include paths (no need to add src folder into include paths)
- Comments changed to doxygen

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Code formatting

Applied code-format.sh script.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>
2020-10-02 13:10:09 +02:00
github-actions[bot]
cf1ca20750 Merge 34e0fefeb3 into dev 2020-10-02 10:26:54 +00:00
Gabor Kiss-Vamosi
34e0fefeb3 fix imgbtn image switching with empty style 2020-10-02 12:26:12 +02:00
Gabor Kiss-Vamosi
a12d54855f Update CHANGELOG.md 2020-10-02 11:35:15 +02:00
ryanpowers
6d1a72b522 Text selection enhancement (#1829)
* Corrected bug in styles of labels with selections

Text selection color (text_selection_color) property was incorrectly
being applied to the text color if there was a selection. The sel_color
property in the label descriptor was initialized to blue. This property
was intended to be the label background color under a selection.

* Add new property for the color of selected text

New property for labels: text_sel_font_color
This property will change the color of the font within selected text.

* Rename text selection color properties

Per feedback from issue #1820, sel_color is now sel_bg_color and
sel_font_color is now sel_color. This results in clearer naming.

Co-authored-by: Ryan Powers <ryan.powers@envision-tek.com>
2020-10-02 11:34:28 +02:00
github-actions[bot]
f37cbafad6 Merge 79d72f9286 into dev 2020-10-02 08:55:42 +00:00
Gabor Kiss-Vamosi
79d72f9286 Fix click focus 2020-10-02 10:54:53 +02:00
Themba Dube
e7bb0382c4 Merge remote-tracking branch 'origin/master' into dev 2020-10-01 10:34:08 -04:00
Gabor Kiss-Vamosi
0b1590d9ac Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-10-01 16:24:01 +02:00
Gabor Kiss-Vamosi
d14e642fc7 fix style transitions with style caching
related to #1825
2020-10-01 16:23:54 +02:00
Martino Facchin
535c3d506f Allow inclusion of local lv_conf_internal.h (#1822)
* Allow inclusion of local lv_conf_internal.h

A wrapper library cna contain an lv_conf.h file and it would be automatically picked up by the buildsystem

* Guard __has_include and simplify code

* Make number sign indentation consistent

Co-authored-by: embeddedt <42941056+embeddedt@users.noreply.github.com>
2020-10-01 13:51:33 +02:00
Gabor Kiss-Vamosi
8bed30db34 handle sub pixel rendering in font loader 2020-10-01 13:28:22 +02:00
Gabor Kiss-Vamosi
f6df9b490e Update CHANGELOG.md 2020-10-01 13:18:00 +02:00
Gabor Kiss-Vamosi
5770a09e73 Update CHANGELOG.md 2020-10-01 13:16:52 +02:00
Ali Rostami
c2c130889d use margin in the header part of calendar. (#1817)
* use margin in the header part of calendar.

* make calendar_init same as before based on new changes of pad and margin in calendar_header.
2020-10-01 13:16:00 +02:00
Jozef Bastek
ed90f36984 VG-Lite: Added support for fill and BLIT
VG-Lite accelerated features:
  - fill (+ transparency)
  - BLIT (+ transparency)

Limitation:
  Image width must be aligned to 16 for VG-Lite to process the buffer.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>
2020-09-30 17:38:25 +02:00
github-actions[bot]
540856a8bc Merge 8c824b265e into dev 2020-09-30 04:55:39 +00:00
Gabor Kiss-Vamosi
8c824b265e style cahce: add margin 2020-09-30 06:55:05 +02:00
github-actions[bot]
f1690be7fc Merge 5a0006cd3c into dev 2020-09-29 07:34:27 +00:00
Gabor Kiss-Vamosi
5a0006cd3c Update ROADMAP.md 2020-09-29 09:33:57 +02:00
github-actions[bot]
25bd804724 Merge 07746a78d5 into dev 2020-09-28 13:32:34 +00:00
Gabor Kiss-Vamosi
07746a78d5 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-09-28 15:31:55 +02:00
Gabor Kiss-Vamosi
a24e3f619f dropdown list fixes with Bidi == RTL 2020-09-28 11:48:27 +02:00
Gabor Kiss-Vamosi
5be1fcadca fix copying base dir in lv_obj_craete 2020-09-28 11:48:06 +02:00
github-actions[bot]
03c526514d Merge 8ff5e23378 into dev 2020-09-28 09:08:17 +00:00
Gabor Kiss-Vamosi
8ff5e23378 Update ROADMAP.md 2020-09-28 11:07:49 +02:00
github-actions[bot]
ef0c8690e4 Merge ce11b4c71c into dev 2020-09-28 08:51:58 +00:00
Gabor Kiss-Vamosi
ce11b4c71c fix build error 2020-09-28 10:51:26 +02:00
github-actions[bot]
0d62025e2c Merge f0fc45eb52 into dev 2020-09-28 08:43:39 +00:00
Gabor Kiss-Vamosi
f0fc45eb52 checkbox: do not play transition on manual state change 2020-09-28 10:43:05 +02:00
github-actions[bot]
115314b140 Merge ffd9b872d9 into dev 2020-09-27 12:47:45 +00:00
Gabor Kiss-Vamosi
ffd9b872d9 fix BIDI support in dropdown list 2020-09-27 14:47:11 +02:00
github-actions[bot]
22fbde4501 Merge 71669c252c into dev 2020-09-23 17:59:22 +00:00
Gabor Kiss-Vamosi
71669c252c Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-09-23 19:58:45 +02:00
Gabor Kiss-Vamosi
672537dcc2 propogate checkbox state change to bullet and label too 2020-09-23 19:26:22 +02:00
github-actions[bot]
a45ff2c574 Merge 6b06ac4b72 into dev 2020-09-23 17:24:37 +00:00
embeddedt
6b06ac4b72 Fix grammar error in README.md 2020-09-23 13:24:00 -04:00
github-actions[bot]
2f7369e771 Merge b2d201dba7 into dev 2020-09-23 10:42:07 +00:00
embeddedt
b2d201dba7 Fix #1795: ensure switch/bar visual state matches logical state (#1805) 2020-09-23 06:41:37 -04:00
github-actions[bot]
695d8e5462 Merge 2b49a7eb28 into dev 2020-09-23 09:00:53 +00:00
Gabor Kiss-Vamosi
2b49a7eb28 add missing style cache invalidation on state change 2020-09-23 11:00:15 +02:00
Gabor Kiss-Vamosi
0b3759201f Update CHANGELOG.md 2020-09-23 10:23:45 +02:00
Ali Rostami
23f5a11340 Table fmt (#1803)
* update lv_obj_refresh_style describtion.

* fmt version of lv_table_set_cell_value added.

* fix a bug.

* add include lv_printf.h

* fix a bug for LV_USE_BIDI in lv_table_set_cell_value_fmt

* fix a missed part for arabic_persian chars in lv_table_set_cell_value
2020-09-23 10:23:37 +02:00
github-actions[bot]
a590f91fd0 Merge 686a3b5271 into dev 2020-09-23 08:14:44 +00:00
Gabor Kiss-Vamosi
686a3b5271 Update ROADMAP.md 2020-09-23 10:14:06 +02:00
Gabor Kiss-Vamosi
27eb84667f Update CHANGELOG.md 2020-09-23 09:59:09 +02:00
jozba
1508320aa8 PXP support for NXP RTxxx MCUs (#1702)
* PXP: Added basic PXP acceleration

PXP accelerated features:
 - fill (+ opacity)
 - BLIT (+ opacity)
 - recoloring (+ opacity)
 - color keying (+ opacity)

Recoloring + color keying simultaneously not supported.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Added abstraction for interrupt handling

Previous imlpementation used IRQ polling on PXP, which doesn't allow
real CPU offload. Therefore added set of callbacks for interrupt
handling that should be implemented by user, with possible RTOS
integration.

Default/example implementation of callbacks for bare metal and FreeRTOS
provided (lv_gpu_nxp_pxp_osa.c), enabled by
LV_USE_GPU_NXP_PXP_DEFAULT_OSA switch, accesible via pxp_default_cfg
structure.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Optimized cache flushing

Previous implementation flushed areas of (LCD width * object height)
size. Cache flush is expensive operation and flushing line by line,
smallest possible area, boost performance by shortening time spent on
cache flushes.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Added documentation for NXP PXP accelerator

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: added missing extern c in header files

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Fixed ifdefs - Removed LV_USE_GPU, fixed internal config

LV_USE_GPU is not intended as a global GPU enable switch. It's used only
for gpu_blend_cb and gpu_fill_cb callbacks, which are obsolete. This
patch removes LV_USE_GPU dependency for PXP code, so it's enabled only
with LV_USE_GPU_NXP_PXP symbol.

Added missing symbols to internal conf, so automatic testd can pass
build step.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Default OSA changed to PXP auto-initialization

Auto init feature added so if user run FreeRTOS or bare-metal, no PXP
Init code is required. Renamed symbol to be more clear.

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Documentation moved to docs repo

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>

* PXP: Fixed alpha configuration

- Coverity issue: AS blend config used uninitialized structure. No
impact on functionality, as blend module is not used (porter-duff blends
in this case)
- Alpha config fixed - swapped alpha values produced different result
from SW render

Signed-off-by: Jozef Bastek <jozef.bastek@nxp.com>
2020-09-23 09:57:38 +02:00
github-actions[bot]
ea16ce5dd0 Merge eb056315c3 into dev 2020-09-22 13:54:10 +00:00
xennex22
eb056315c3 Changed non-debug macro expansion (#1808) 2020-09-22 09:53:36 -04:00
github-actions[bot]
64a4fff635 Merge ddf33b2fd9 into dev 2020-09-22 09:24:13 +00:00
Gabor Kiss-Vamosi
ddf33b2fd9 release.py: update docs only in the end 2020-09-22 11:23:34 +02:00
Gabor Kiss-Vamosi
e9476f4767 Merge branch 'dev' of https://github.com/lvgl/lvgl into dev 2020-09-22 10:51:09 +02:00
Gabor Kiss-Vamosi
04e2b94c06 Merge branch 'master' into dev 2020-09-22 10:46:38 +02:00
github-actions[bot]
39f4c15876 Merge 783dc6be9a into dev 2020-09-22 08:37:22 +00:00
github-actions[bot]
39f1b363fd Merge 18db4d83bc into dev 2020-09-22 07:27:24 +00:00
Gabor Kiss-Vamosi
458046b9b0 add v7.7 to changelog 2020-09-22 09:24:59 +02:00
github-actions[bot]
23ba19d068 Merge 4d87007c95 into dev 2020-09-22 04:21:17 +00:00
github-actions[bot]
0576300981 Merge 2415f99a20 into dev 2020-09-22 04:21:00 +00:00
github-actions[bot]
77fd862b3f Merge 1c930dc8fb into dev 2020-09-22 04:20:10 +00:00
github-actions[bot]
259907b788 Merge 83c9145072 into dev 2020-09-22 04:18:24 +00:00
github-actions[bot]
02afe7f82c Merge 94a6dc08d8 into dev 2020-09-21 22:05:35 +00:00
tosriram
5ef1df9357 Extend maximum number of table cell styles from 4 to 16 (#1800) 2020-09-21 11:50:54 -04:00
github-actions[bot]
a81574543b Merge cbd3393d7c into dev 2020-09-21 09:58:26 +00:00
github-actions[bot]
b09d5a846c Merge 2820cf897f into dev 2020-09-17 13:09:42 +00:00
github-actions[bot]
33dbc82a0c Merge 18a4869e62 into dev 2020-09-17 13:09:41 +00:00
github-actions[bot]
adce9d72fc Merge d90f5d0144 into dev 2020-09-17 11:26:04 +00:00
github-actions[bot]
9461e48998 Merge 565643e883 into dev 2020-09-16 17:55:03 +00:00
github-actions[bot]
132e6d11b4 Merge 7756d70705 into dev 2020-09-16 13:23:52 +00:00
github-actions[bot]
dbbf4a406f Merge be4f7a76d4 into dev 2020-09-16 13:22:05 +00:00
github-actions[bot]
537456cea5 Merge d547d8afe1 into dev 2020-09-16 09:51:23 +00:00
github-actions[bot]
fb6e3518ea Merge 2614d1342e into dev 2020-09-15 10:30:09 +00:00
github-actions[bot]
0287b759ac Merge 3c6741b11c into dev 2020-09-15 10:20:27 +00:00
Gabor Kiss-Vamosi
9b953abbd2 Update dev version 2020-09-15 11:56:57 +02:00
69 changed files with 5549 additions and 368 deletions

View File

@@ -2,9 +2,9 @@ name: Build Micropython with LVGL submodule
on:
push:
branches: [ master ]
branches: [ master, dev ]
pull_request:
branches: [ master ]
branches: [ master, dev ]
jobs:
build:

View File

@@ -1,5 +1,38 @@
# Changelog
## v7.7.0 (20.10.2020)
### New features
- Add PXP GPU support (for NXP MCUs)
- Add VG-Lite GPU support (for NXP MCUs)
- Allow max. 16 cell types for table
- Add `lv_table_set_text_fmt()`
- Use margin on calendar header to set distances and padding to the size of the header
- Add `text_sel_bg` style proeprty
### Bugfixes
- Theme update to support text selection background
- Fix imgbtn state change
- Support RTL in table (draw columns right to left)
- Support RTL in pretty layout (draw columns right to left)
- Skip objects in groups if they are in disabled state
- Fix dropdown selection with RTL basedirection
- Fix rectangle border drawing with large width
- Fix `lv_win_clean()`
## v7.6.1 (06.10.2020)
### Bugfixes
- Fix BIDI support in dropdown list
- Fix copying base dir in `lv_obj_create`
- Handle sub pixel rendering in font loader
- Fix transitions with style caching
- Fix click focus
- Fix imgbtn image switching with empty style
- Material theme: do not set the text font to allow easy global font change
## v7.6.0 (22.09.2020)
### New features

View File

@@ -121,7 +121,7 @@ For more examples see the [lv_examples](https://github.com/lvgl/lv_examples) rep
### Button with label
```c
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button to the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 100, 50); /*Set its size*/
lv_obj_set_event_cb(btn, btn_event_cb); /*Assign a callback to the button*/

View File

@@ -6,6 +6,10 @@ This list indicates only the current intention and can be changed.
## v8
Planned to September/October 2020
- Create an `lv_components` repository for compley widgets
- It makes the core LVGL leaner
- In `lv_components` we can have a lot and specific widgets
- Good place for contribution
- New scrolling:
- See [feat/new-scroll](https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue.
- Remove `lv_page` and support scrolling on `lv_obj`
@@ -18,11 +22,12 @@ Planned to September/October 2020
- New layouts:
- See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue
- [CSS Grid](https://css-tricks.com/snippets/css/a-guide-to-grid/)-like layout support
- Work in progress
- [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)-like layout support
- Remove `lv_cont` and support layouts on `lv_obj`
- Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier
- Work in progress
- Remove the align parameter from `lv_canvas_draw_text`
- RGB888 support [#1722](https://github.com/lvgl/lvgl/issues/1722)
- Make the `copy` parameter of `create` functions deprecated
## v8.1
- Add radio button widget
@@ -32,8 +37,19 @@ Planned to September/October 2020
- Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658)
- Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660)
- Consider direct binary font format support
- Remove the copy paramter from create functions
- Style selectors and style-based states See [#1832](https://github.com/lvgl/lvgl/issues/1832)
## v10
- Remove property level states
## Ideas
- 9-patch support for `lv_imgbtn`.
- lv_mem_alloc_aligned(size, align)
- Text node. See [#1701](https://github.com/lvgl/lvgl/issues/1701#issuecomment-699479408)
- RGB888 support [#1722](https://github.com/lvgl/lvgl/issues/1722)
- Consider ARGB4444, ARGB1555 format
- CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736)
- Optmize font decompression
- Switch to RGBA colors in styles

View File

@@ -1,6 +1,6 @@
{
"name": "lvgl",
"version": "7.6.0",
"version": "7.7.0",
"keywords": "graphics, gui, embedded, tft, lvgl",
"description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.",
"repository": {

View File

@@ -1,5 +1,5 @@
name=lvgl
version=7.6.0
version=7.7.0
author=kisvegabor
maintainer=kisvegabor,embeddedt,pete-pjb
sentence=Full-featured Graphics Library for Embedded Systems

View File

@@ -1,6 +1,6 @@
/**
* @file lv_conf.h
* Configuration file for v7.6.0-dev
* Configuration file for v7.7.0-dev
*/
/*
@@ -195,6 +195,19 @@ typedef void * lv_group_user_data_t;
e.g. "stm32f769xx.h" or "stm32f429xx.h" */
#define LV_GPU_DMA2D_CMSIS_INCLUDE
/*1: Use PXP for CPU off-load on NXP RTxxx platforms */
#define LV_USE_GPU_NXP_PXP 0
/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c)
* and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS
* has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected.
*0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init()
* */
#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0
/*1: Use VG-Lite for CPU offload on NXP RTxxx platforms */
#define LV_USE_GPU_NXP_VG_LITE 0
/* 1: Enable file system (might be required for images */
#define LV_USE_FILESYSTEM 1
#if LV_USE_FILESYSTEM
@@ -249,9 +262,14 @@ typedef void * lv_img_decoder_user_data_t;
/* Define a custom attribute to `lv_disp_flush_ready` function */
#define LV_ATTRIBUTE_FLUSH_READY
/* Required alignment size for buffers */
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE
/* 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))) */
* 4 or 8 byte boundary. Some HW may need even 32 or 64 bytes.
* This alignment will be explicitly applied where needed.
* LV_ATTRIBUTE_MEM_ALIGN_SIZE should be used to specify required align size.
* E.g. __attribute__((aligned(LV_ATTRIBUTE_MEM_ALIGN_SIZE))) */
#define LV_ATTRIBUTE_MEM_ALIGN
/* Attribute to mark large constant arrays for example
@@ -709,8 +727,10 @@ typedef void * lv_obj_user_data_t;
#define LV_USE_TABLE 1
#if LV_USE_TABLE
# define LV_TABLE_COL_MAX 12
# define LV_TABLE_CELL_STYLE_CNT 4
#endif
/*Tab (dependencies: lv_page, lv_btnm)*/
#define LV_USE_TABVIEW 1
# if LV_USE_TABVIEW != 0

2
lvgl.h
View File

@@ -15,7 +15,7 @@ extern "C" {
* CURRENT VERSION OF LVGL
***************************/
#define LVGL_VERSION_MAJOR 7
#define LVGL_VERSION_MINOR 6
#define LVGL_VERSION_MINOR 7
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO ""

View File

@@ -54,7 +54,7 @@ import sys
upstream_org_url = "https://github.com/lvgl/"
workdir = "./release_tmp"
proj_list = [ "lv_sim_eclipse_sdl"]
proj_list = [ "lv_sim_eclipse_sdl", "lv_sim_emscripten"]
ver_major = -1
ver_minor = -1
@@ -87,7 +87,7 @@ def define_set(fn, name, value):
print("In " + fn + " set " + name + " to " + value)
new_content = ""
s = r'^ *# *define +' + str(name).rstrip()
s = r'^ *# *define +' + str(name).rstrip() + ' +'
f = open(fn, "r")
for i in f.read().splitlines():
@@ -108,10 +108,6 @@ def clone_repos():
cmd("mkdir " + workdir)
os.chdir(workdir)
#For debuging just copy the repos
#cmd("cp -a ../repos/. .")
#return
cmd("git clone " + upstream("lvgl") + "; cd lvgl; git checkout master; git remote update origin --prune; ")
cmd("git clone " + upstream("lv_examples") + "; cd lv_examples; git checkout master; git remote update origin --prune; ")
cmd("git clone " + upstream("lv_drivers") + "; cd lv_drivers; git checkout master; git remote update origin --prune; ")
@@ -325,10 +321,6 @@ def publish_master():
cmd("cd lv_examples; " + pub_cmd)
cmd("cd lv_drivers; " + pub_cmd)
pub_cmd = "git push origin latest; git push origin " + ver_str
cmd("cd docs; " + pub_cmd)
cmd("cd docs; git checkout master; python 2.7 ./update.py " + release_br)
pub_cmd = "git push origin master"
cmd("cd blog; " + pub_cmd)
@@ -413,8 +405,6 @@ def publish_dev_and_master():
pub_cmd = "git checkout master; git push origin master"
cmd("cd lvgl; " + pub_cmd)
cmd("cd docs; git checkout master; python 2.7 ./update.py latest dev")
def projs_update():
global proj_list, release_br, ver_str
for p in proj_list:
@@ -450,13 +440,15 @@ def projs_update():
os.chdir("../")
def docs_update_all():
cmd("cd docs; git checkout master; python 2.7 ./update.py master dev " + release_br)
def cleanup():
os.chdir("../")
cmd("rm -fr " + workdir)
if __name__ == '__main__':
dev_prepare = 'bugfix'
dev_prepare = 'minor'
if(len(sys.argv) != 2):
print("Missing argument. Usage ./release.py bugfix | minor | major")
print("Use minor by deafult")
@@ -486,6 +478,10 @@ if __name__ == '__main__':
publish_master()
projs_update()
dev_ver_major = "7"
dev_ver_minor = "7"
dev_ver_patch = "0"
dev_ver_str = "v7.7.0"
if dev_prepare == 'bugfix':
ver_patch = str(int(ver_patch) + 1)
@@ -497,15 +493,14 @@ if __name__ == '__main__':
docs_update_latest_version()
else:
#merge_from_dev()
get_lvgl_version("master")
merge_from_dev()
if dev_prepare == 'minor':
ver_minor = str(int(ver_minor) + 1)
ver_major = dev_ver_major
ver_minor = str(int(dev_ver_minor) + 1)
ver_patch = "0"
else:
ver_major = str(int(ver_major) + 1)
ver_major = str(int(dev_ver_major) + 1)
ver_minor = "0"
ver_patch = "0"
@@ -517,5 +512,6 @@ if __name__ == '__main__':
docs_update_dev_version()
publish_dev_and_master()
docs_update_all();
cleanup()

View File

@@ -476,6 +476,37 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
# endif
#endif
/*1: Use PXP for CPU off-load on NXP RTxxx platforms */
#ifndef LV_USE_GPU_NXP_PXP
# ifdef CONFIG_LV_USE_GPU_NXP_PXP
# define LV_USE_GPU_NXP_PXP CONFIG_LV_USE_GPU_NXP_PXP
# else
# define LV_USE_GPU_NXP_PXP 0
# endif
#endif
/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c)
* and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS
* has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected.
*0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init()
* */
#ifndef LV_USE_GPU_NXP_PXP_AUTO_INIT
# ifdef CONFIG_LV_USE_GPU_NXP_PXP_AUTO_INIT
# define LV_USE_GPU_NXP_PXP_AUTO_INIT CONFIG_LV_USE_GPU_NXP_PXP_AUTO_INIT
# else
# define LV_USE_GPU_NXP_PXP_AUTO_INIT 0
# endif
#endif
/*1: Use VG-Lite for CPU offload on NXP RTxxx platforms */
#ifndef LV_USE_GPU_NXP_VG_LITE
# ifdef CONFIG_LV_USE_GPU_NXP_VG_LITE
# define LV_USE_GPU_NXP_VG_LITE CONFIG_LV_USE_GPU_NXP_VG_LITE
# else
# define LV_USE_GPU_NXP_VG_LITE 0
# endif
#endif
/* 1: Enable file system (might be required for images */
#ifndef LV_USE_FILESYSTEM
# ifdef CONFIG_LV_USE_FILESYSTEM
@@ -600,9 +631,20 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
# endif
#endif
/* Required alignment size for buffers */
#ifndef LV_ATTRIBUTE_MEM_ALIGN_SIZE
# ifdef CONFIG_LV_ATTRIBUTE_MEM_ALIGN_SIZE
# define LV_ATTRIBUTE_MEM_ALIGN_SIZE CONFIG_LV_ATTRIBUTE_MEM_ALIGN_SIZE
# else
# define LV_ATTRIBUTE_MEM_ALIGN_SIZE
# endif
#endif
/* 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))) */
* 4 or 8 byte boundary. Some HW may need even 32 or 64 bytes.
* This alignment will be explicitly applied where needed.
* LV_ATTRIBUTE_MEM_ALIGN_SIZE should be used to specify required align size.
* E.g. __attribute__((aligned(LV_ATTRIBUTE_MEM_ALIGN_SIZE))) */
#ifndef LV_ATTRIBUTE_MEM_ALIGN
# ifdef CONFIG_LV_ATTRIBUTE_MEM_ALIGN
# define LV_ATTRIBUTE_MEM_ALIGN CONFIG_LV_ATTRIBUTE_MEM_ALIGN
@@ -1848,7 +1890,15 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
# define LV_TABLE_COL_MAX 12
# endif
#endif
#ifndef LV_TABLE_CELL_STYLE_CNT
# ifdef CONFIG_LV_TABLE_CELL_STYLE_CNT
# define LV_TABLE_CELL_STYLE_CNT CONFIG_LV_TABLE_CELL_STYLE_CNT
# else
# define LV_TABLE_CELL_STYLE_CNT 4
# endif
#endif
#endif
/*Tab (dependencies: lv_page, lv_btnm)*/
#ifndef LV_USE_TABVIEW

View File

@@ -120,7 +120,6 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
return disp->sys_layer;
}
/**
* Assign a screen to a display.
* @param disp pointer to a display where to assign the screen
@@ -317,12 +316,6 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
*/
uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_disp_get_inactive_time: no display registered");
return 0;
}
if(disp) return lv_tick_elaps(disp->last_activity_time);
lv_disp_t * d;

View File

@@ -184,7 +184,6 @@ static inline void lv_scr_load(lv_obj_t * scr)
lv_disp_load_scr(scr);
}
/**********************
* MACROS
**********************/

View File

@@ -488,8 +488,9 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
can_move = true;
if(obj_next == NULL) continue;
if(lv_obj_get_state(*obj_next, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED) continue;
/*Hidden objects don't receive focus*/
/*Hidden and disabled objects don't receive focus*/
if(!lv_obj_get_hidden(*obj_next)) break;
}

View File

@@ -1162,14 +1162,14 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(lv_obj_is_protected(indev_obj_act, LV_PROTECT_CLICK_FOCUS) == false &&
proc->types.pointer.last_pressed != obj_to_focus) {
#if LV_USE_GROUP
lv_group_t * g_act = lv_obj_get_group(indev_obj_act);
lv_group_t * g_act = lv_obj_get_group(obj_to_focus);
lv_group_t * g_prev = proc->types.pointer.last_pressed ? lv_obj_get_group(proc->types.pointer.last_pressed) : NULL;
/*If both the last and act. obj. are in the same group (or no group but it's also the same) */
if(g_act == g_prev) {
/*The objects are in a group*/
if(g_act) {
lv_group_focus_obj(indev_obj_act);
lv_group_focus_obj(obj_to_focus);
if(indev_reset_check(proc)) return;
}
/*The object are not in group*/
@@ -1218,7 +1218,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
/*Focus to the act. in its group*/
if(g_act) {
lv_group_focus_obj(indev_obj_act);
lv_group_focus_obj(obj_to_focus);
if(indev_reset_check(proc)) return;
}
else {
@@ -1236,9 +1236,9 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(indev_reset_check(proc)) return;
}
lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL);
lv_signal_send(obj_to_focus, LV_SIGNAL_FOCUS, NULL);
if(indev_reset_check(proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL);
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL);
if(indev_reset_check(proc)) return;
#endif
proc->types.pointer.last_pressed = obj_to_focus;

View File

@@ -27,6 +27,11 @@
#include <stdint.h>
#include <string.h>
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
#include "../lv_gpu/lv_gpu_nxp_pxp.h"
#include "../lv_gpu/lv_gpu_nxp_pxp_osa.h"
#endif
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
@@ -194,6 +199,13 @@ void lv_init(void)
lv_gpu_stm32_dma2d_init();
#endif
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
if(lv_gpu_nxp_pxp_init(&pxp_default_cfg) != LV_RES_OK) {
LV_LOG_ERROR("PXP init error. STOP.\n");
for(; ;) ;
}
#endif
_lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_style_trans_t));
_lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
@@ -360,7 +372,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
#if LV_USE_GROUP
new_obj->group_p = NULL;
#endif
/*Set attributes*/
@@ -405,6 +416,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
_lv_memcpy(&new_obj->user_data, &copy->user_data, sizeof(lv_obj_user_data_t));
#endif
new_obj->base_dir = copy->base_dir;
/*Copy realign*/
#if LV_USE_OBJ_REALIGN
new_obj->realign.align = copy->realign.align;
@@ -1729,13 +1742,16 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
obj->state = new_state;
if(cmp_res == STYLE_COMPARE_SAME) return;
if(cmp_res == STYLE_COMPARE_SAME) {
return;
}
#if LV_USE_ANIMATION == 0
if(cmp_res == STYLE_COMPARE_DIFF) lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
else if(cmp_res == STYLE_COMPARE_VISUAL_DIFF) lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
#else
for(part = 0; part < _LV_OBJ_PART_REAL_LAST; part++) {
lv_style_list_t * style_list = lv_obj_get_style_list(obj, part);
if(style_list == NULL) break; /*No more style lists*/
@@ -1782,8 +1798,16 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
}
}
if(cmp_res == STYLE_COMPARE_DIFF) lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
if(cmp_res == STYLE_COMPARE_VISUAL_DIFF) {
invalidate_style_cache(obj, part, LV_STYLE_PROP_ALL);
}
if(cmp_res == STYLE_COMPARE_VISUAL_DIFF) lv_obj_invalidate(obj);
}
if(cmp_res == STYLE_COMPARE_VISUAL_DIFF) {
lv_obj_invalidate(obj);
}
#endif
}
@@ -2576,9 +2600,6 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl
bool def = false;
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_BG_GRAD_DIR:
if(list->bg_grad_dir_none) def = true;
break;
case LV_STYLE_CLIP_CORNER:
if(list->clip_corner_off) def = true;
break;
@@ -2616,6 +2637,12 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl
case LV_STYLE_PAD_RIGHT:
if(list->pad_all_zero) def = true;
break;
case LV_STYLE_MARGIN_TOP:
case LV_STYLE_MARGIN_BOTTOM:
case LV_STYLE_MARGIN_LEFT:
case LV_STYLE_MARGIN_RIGHT:
if(list->margin_all_zero) def = true;
break;
case LV_STYLE_BG_BLEND_MODE:
case LV_STYLE_BORDER_BLEND_MODE:
case LV_STYLE_IMAGE_BLEND_MODE:
@@ -2627,6 +2654,9 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl
case LV_STYLE_VALUE_BLEND_MODE:
if(list->blend_mode_all_normal) def = true;
break;
case LV_STYLE_TEXT_DECOR:
if(list->text_decor_none) def = true;
break;
}
if(def) {
@@ -3496,7 +3526,8 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_
draw_dsc->font = lv_obj_get_style_text_font(obj, part);
if(draw_dsc->sel_start != LV_DRAW_LABEL_NO_TXT_SEL && draw_dsc->sel_end != LV_DRAW_LABEL_NO_TXT_SEL) {
draw_dsc->color = lv_obj_get_style_text_sel_color(obj, part);
draw_dsc->sel_color = lv_obj_get_style_text_sel_color(obj, part);
draw_dsc->sel_bg_color = lv_obj_get_style_text_sel_bg_color(obj, part);
}
#if LV_USE_BIDI
@@ -4058,8 +4089,9 @@ static void report_style_mod_core(void * style, lv_obj_t * obj)
uint8_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * class = lv_style_list_get_style(list, ci);
if(class == style || style == NULL) {
/* changed class to _class to allow compilation as c++ */
lv_style_t * _class = lv_style_list_get_style(list, ci);
if(_class == style || style == NULL) {
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
break;
}
@@ -4279,14 +4311,18 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
lv_style_list_t * style_list = lv_obj_get_style_list(obj, part);
lv_style_t * style_trans = _lv_style_list_get_transition_style(style_list);
bool cahche_ori = style_list->ignore_cache;
/*Get the previous and current values*/
if((prop & 0xF) < LV_STYLE_ID_COLOR) { /*Int*/
style_list->skip_trans = 1;
style_list->ignore_cache = 1;
obj->state = prev_state;
lv_style_int_t int1 = _lv_obj_get_style_int(obj, part, prop);
obj->state = new_state;
lv_style_int_t int2 = _lv_obj_get_style_int(obj, part, prop);
style_list->skip_trans = 0;
style_list->ignore_cache = cahche_ori;
if(int1 == int2) return NULL;
obj->state = prev_state;
@@ -4311,11 +4347,13 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
}
else if((prop & 0xF) < LV_STYLE_ID_OPA) { /*Color*/
style_list->skip_trans = 1;
style_list->ignore_cache = 1;
obj->state = prev_state;
lv_color_t c1 = _lv_obj_get_style_color(obj, part, prop);
obj->state = new_state;
lv_color_t c2 = _lv_obj_get_style_color(obj, part, prop);
style_list->skip_trans = 0;
style_list->ignore_cache = cahche_ori;
if(c1.full == c2.full) return NULL;
obj->state = prev_state;
@@ -4331,11 +4369,13 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
}
else if((prop & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/
style_list->skip_trans = 1;
style_list->ignore_cache = 1;
obj->state = prev_state;
lv_opa_t o1 = _lv_obj_get_style_opa(obj, part, prop);
obj->state = new_state;
lv_opa_t o2 = _lv_obj_get_style_opa(obj, part, prop);
style_list->skip_trans = 0;
style_list->ignore_cache = cahche_ori;
if(o1 == o2) return NULL;
@@ -4353,10 +4393,12 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
else { /*Ptr*/
obj->state = prev_state;
style_list->skip_trans = 1;
style_list->ignore_cache = 1;
const void * p1 = _lv_obj_get_style_ptr(obj, part, prop);
obj->state = new_state;
const void * p2 = _lv_obj_get_style_ptr(obj, part, prop);
style_list->skip_trans = 0;
style_list->ignore_cache = cahche_ori;
if(memcmp(&p1, &p2, sizeof(const void *)) == 0) return NULL;
obj->state = prev_state;
@@ -4542,7 +4584,6 @@ static bool style_prop_is_cacheble(lv_style_property_t prop)
switch(prop) {
case LV_STYLE_PROP_ALL:
case LV_STYLE_BG_GRAD_DIR:
case LV_STYLE_CLIP_CORNER:
case LV_STYLE_TEXT_LETTER_SPACE:
case LV_STYLE_TEXT_LINE_SPACE:
@@ -4566,6 +4607,10 @@ static bool style_prop_is_cacheble(lv_style_property_t prop)
case LV_STYLE_PAD_BOTTOM:
case LV_STYLE_PAD_LEFT:
case LV_STYLE_PAD_RIGHT:
case LV_STYLE_MARGIN_TOP:
case LV_STYLE_MARGIN_BOTTOM:
case LV_STYLE_MARGIN_LEFT:
case LV_STYLE_MARGIN_RIGHT:
case LV_STYLE_BG_BLEND_MODE:
case LV_STYLE_BORDER_BLEND_MODE:
case LV_STYLE_IMAGE_BLEND_MODE:
@@ -4616,7 +4661,6 @@ static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop)
list->bg_opa_transp = bg_opa == LV_OPA_TRANSP ? 1 : 0;
list->bg_opa_cover = bg_opa == LV_OPA_COVER ? 1 : 0;
list->bg_grad_dir_none = lv_obj_get_style_bg_grad_dir(obj, part) == LV_GRAD_DIR_NONE ? 1 : 0;
list->border_width_zero = lv_obj_get_style_border_width(obj, part) == 0 ? 1 : 0;
list->border_side_full = lv_obj_get_style_border_side(obj, part) == LV_BORDER_SIDE_FULL ? 1 : 0;
list->border_post_off = lv_obj_get_style_border_post(obj, part) == 0 ? 1 : 0;
@@ -4645,6 +4689,14 @@ static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop)
list->pad_all_zero = 0;
}
list->margin_all_zero = 1;
if(lv_obj_get_style_margin_top(obj, part) != 0 ||
lv_obj_get_style_margin_bottom(obj, part) != 0 ||
lv_obj_get_style_margin_left(obj, part) != 0 ||
lv_obj_get_style_margin_right(obj, part) != 0) {
list->margin_all_zero = 0;
}
list->blend_mode_all_normal = 1;
#if LV_USE_BLEND_MODES
if(lv_obj_get_style_bg_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
@@ -4744,6 +4796,10 @@ static void style_snapshot(lv_obj_t * obj, uint8_t part, style_snapshot_t * shot
lv_draw_img_dsc_init(&shot->img);
lv_draw_line_dsc_init(&shot->line);
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
bool trans_ori = list->skip_trans;
list->skip_trans = 1;
lv_obj_init_draw_rect_dsc(obj, part, &shot->rect);
lv_obj_init_draw_label_dsc(obj, part, &shot->label);
lv_obj_init_draw_img_dsc(obj, part, &shot->img);
@@ -4775,6 +4831,7 @@ static void style_snapshot(lv_obj_t * obj, uint8_t part, style_snapshot_t * shot
shot->border_post = lv_obj_get_style_border_post(obj, part);
_lv_obj_disable_style_caching(obj, false);
list->skip_trans = trans_ori;
}
static style_snapshot_res_t style_snapshot_compare(style_snapshot_t * shot1, style_snapshot_t * shot2)

View File

@@ -1527,11 +1527,11 @@ bool lv_debug_check_obj_valid(const lv_obj_t * obj);
# if LV_USE_ASSERT_NULL /*Use at least LV_ASSERT_NULL if enabled*/
# define LV_ASSERT_OBJ(obj_p, obj_type) LV_ASSERT_NULL(obj_p)
# else
# define LV_ASSERT_OBJ(obj_p, obj_type) true
# define LV_ASSERT_OBJ(obj_p, obj_type)
# endif
# endif
#else
# define LV_ASSERT_OBJ(obj, obj_type) true
# define LV_ASSERT_OBJ(obj, obj_type)
#endif

View File

@@ -163,6 +163,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, sca
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_BG_COLOR, text_sel_bg_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar)

View File

@@ -827,8 +827,9 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_int(class, prop, &value_act);
/* changed class to _class to allow compilation as c++ */
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_int(_class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
@@ -880,8 +881,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_color(class, prop, &value_act);
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_color(_class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;
@@ -930,8 +931,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_opa(class, prop, &value_act);
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_opa(_class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;
@@ -980,8 +981,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_ptr(class, prop, &value_act);
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_ptr(_class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;

View File

@@ -165,6 +165,7 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_COLOR, 0x8, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_BG_COLOR, 0x8, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_FONT, 0x8, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_INHERIT),
@@ -234,10 +235,10 @@ typedef struct {
uint32_t clip_corner_off : 1;
uint32_t transform_all_zero : 1;
uint32_t pad_all_zero : 1;
uint32_t margin_all_zero : 1;
uint32_t blend_mode_all_normal : 1;
uint32_t bg_opa_transp : 1;
uint32_t bg_opa_cover : 1;
uint32_t bg_grad_dir_none : 1;
uint32_t border_width_zero : 1;
uint32_t border_side_full : 1;
@@ -618,13 +619,13 @@ bool lv_debug_check_style_list(const lv_style_list_t * list);
# define LV_ASSERT_STYLE_LIST(list_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE_LIST(list_p), "Invalid style list", list_p);
# endif
# else
# define LV_ASSERT_STYLE(style_p) true
# define LV_ASSERT_STYLE_LIST(list_p) true
# define LV_ASSERT_STYLE(style_p)
# define LV_ASSERT_STYLE_LIST(list_p)
# endif
#else
# define LV_ASSERT_STYLE(p) true
# define LV_ASSERT_STYLE_LIST(p) true
# define LV_ASSERT_STYLE(p)
# define LV_ASSERT_STYLE_LIST(p)
#endif
#ifdef __cplusplus

View File

@@ -12,13 +12,20 @@
#include "../lv_hal/lv_hal_disp.h"
#include "../lv_core/lv_refr.h"
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#if LV_USE_GPU_NXP_PXP
#include "../lv_gpu/lv_gpu_nxp_pxp.h"
#elif LV_USE_GPU_NXP_VG_LITE
#include "../lv_gpu/lv_gpu_nxp_vglite.h"
#elif LV_USE_GPU_STM32_DMA2D
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#endif
/*********************
* DEFINES
*********************/
#define GPU_SIZE_LIMIT 240
/**********************
* TYPEDEFS
**********************/
@@ -335,9 +342,19 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
disp->driver.gpu_fill_cb(&disp->driver, disp_buf, disp_w, draw_area, color);
return;
}
#endif
#if LV_USE_GPU_STM32_DMA2D
#elif LV_USE_GPU_NXP_PXP
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_PXP_FILL_SIZE_LIMIT) {
lv_gpu_nxp_pxp_fill(disp_buf, disp_w, draw_area, color, opa);
return;
}
#elif LV_USE_GPU_NXP_VG_LITE
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_VG_LITE_FILL_SIZE_LIMIT) {
if(lv_gpu_nxp_vglite_fill(disp_buf, disp_w, lv_area_get_height(disp_area), draw_area, color, opa) == LV_RES_OK) {
return;
}
/* Fall down to SW render in case of error */
}
#elif LV_USE_GPU_STM32_DMA2D
if(lv_area_get_size(draw_area) >= 240) {
lv_gpu_stm32_dma2d_fill(disp_buf_first, disp_w, color, draw_area_w, draw_area_h);
return;
@@ -351,7 +368,20 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
}
/*No mask with opacity*/
else {
#if LV_USE_GPU
#if LV_USE_GPU_NXP_PXP
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT) {
lv_gpu_nxp_pxp_fill(disp_buf, disp_w, draw_area, color, opa);
return;
}
#elif LV_USE_GPU_NXP_VG_LITE
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_VG_LITE_FILL_OPA_SIZE_LIMIT) {
if(lv_gpu_nxp_vglite_fill(disp_buf, disp_w, lv_area_get_height(disp_area), draw_area, color, opa) == LV_RES_OK) {
return;
}
/* Fall down to SW render in case of error */
}
#elif LV_USE_GPU
if(disp->driver.gpu_blend_cb && lv_area_get_size(draw_area) > GPU_SIZE_LIMIT) {
for(x = 0; x < draw_area_w ; x++) blend_buf[x].full = color.full;
@@ -726,7 +756,43 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
#endif
if(opa > LV_OPA_MAX) {
#if LV_USE_GPU_STM32_DMA2D
#if LV_USE_GPU_NXP_PXP
if(lv_area_get_size(draw_area) >= GPU_NXP_PXP_BLIT_SIZE_LIMIT) {
lv_gpu_nxp_pxp_blit(disp_buf_first, disp_w, map_buf_first, map_w, draw_area_w, draw_area_h, opa);
return;
}
#elif (LV_USE_GPU_NXP_VG_LITE)
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_VG_LITE_BLIT_SIZE_LIMIT) {
lv_gpu_nxp_vglite_blit_info_t blit;
blit.src = map_buf;
blit.src_width = draw_area_w;
blit.src_height = draw_area_h;
blit.src_stride = lv_area_get_width(map_area) * sizeof(lv_color_t);
blit.src_area.x1 = (draw_area->x1 - (map_area->x1 - disp_area->x1));
blit.src_area.y1 = (draw_area->y1 - (map_area->y1 - disp_area->y1));
blit.src_area.x2 = blit.src_area.x1 + draw_area_w;
blit.src_area.y2 = blit.src_area.y1 + draw_area_h;
blit.dst = disp_buf;
blit.dst_width = lv_area_get_width(disp_area);
blit.dst_height = lv_area_get_height(disp_area);
blit.dst_stride = lv_area_get_width(disp_area) * sizeof(lv_color_t);
blit.dst_area.x1 = draw_area->x1;
blit.dst_area.y1 = draw_area->y1;
blit.dst_area.x2 = blit.dst_area.x1 + draw_area_w;
blit.dst_area.y2 = blit.dst_area.y1 + draw_area_h;
blit.opa = opa;
if(lv_gpu_nxp_vglite_blit(&blit) == LV_RES_OK) {
return;
}
/* Fall down to SW render in case of error */
}
#elif LV_USE_GPU_STM32_DMA2D
if(lv_area_get_size(draw_area) >= 240) {
lv_gpu_stm32_dma2d_copy(disp_buf_first, disp_w, map_buf_first, map_w, draw_area_w, draw_area_h);
return;
@@ -741,7 +807,43 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
}
}
else {
#if LV_USE_GPU_STM32_DMA2D
#if LV_USE_GPU_NXP_PXP
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT) {
lv_gpu_nxp_pxp_blit(disp_buf_first, disp_w, map_buf_first, map_w, draw_area_w, draw_area_h, opa);
return;
}
#elif (LV_USE_GPU_NXP_VG_LITE)
if(lv_area_get_size(draw_area) >= LV_GPU_NXP_VG_LITE_BLIT_OPA_SIZE_LIMIT) {
lv_gpu_nxp_vglite_blit_info_t blit;
blit.src = map_buf;
blit.src_width = lv_area_get_width(map_area);
blit.src_height = lv_area_get_height(map_area);
blit.src_stride = lv_area_get_width(map_area) * sizeof(lv_color_t);
blit.src_area.x1 = (draw_area->x1 - (map_area->x1 - disp_area->x1));
blit.src_area.y1 = (draw_area->y1 - (map_area->y1 - disp_area->y1));
blit.src_area.x2 = blit.src_area.x1 + draw_area_w;
blit.src_area.y2 = blit.src_area.y1 + draw_area_h;
blit.dst = disp_buf;
blit.dst_width = lv_area_get_width(disp_area);
blit.dst_height = lv_area_get_height(disp_area);
blit.dst_stride = lv_area_get_width(disp_area) * sizeof(lv_color_t);
blit.dst_area.x1 = draw_area->x1;
blit.dst_area.y1 = draw_area->y1;
blit.dst_area.x2 = blit.dst_area.x1 + draw_area_w;
blit.dst_area.y2 = blit.dst_area.y1 + draw_area_h;
blit.opa = opa;
if(lv_gpu_nxp_vglite_blit(&blit) == LV_RES_OK) {
return;
}
/* Fall down to SW render in case of error */
}
#elif LV_USE_GPU_STM32_DMA2D
if(lv_area_get_size(draw_area) >= 240) {
lv_gpu_stm32_dma2d_blend(disp_buf_first, disp_w, map_buf_first, opa, map_w, draw_area_w, draw_area_h);
return;

View File

@@ -13,8 +13,11 @@
#include "../lv_core/lv_refr.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_math.h"
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#if LV_USE_GPU_STM32_DMA2D
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#elif LV_USE_GPU_NXP_PXP
#include "../lv_gpu/lv_gpu_nxp_pxp.h"
#endif
/*********************
* DEFINES
@@ -355,6 +358,23 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
_lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, draw_dsc->opa,
draw_dsc->blend_mode);
}
#if LV_USE_GPU_NXP_PXP
/* Simple case without masking and transformations */
else if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE && alpha_byte == false &&
chroma_key == true && draw_dsc->recolor_opa == LV_OPA_TRANSP) { /* copy with color keying (+ alpha) */
lv_gpu_nxp_pxp_enable_color_key();
_lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, draw_dsc->opa,
draw_dsc->blend_mode);
lv_gpu_nxp_pxp_disable_color_key();
}
else if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE && alpha_byte == false &&
chroma_key == false && draw_dsc->recolor_opa != LV_OPA_TRANSP) { /* copy with recolor (+ alpha) */
lv_gpu_nxp_pxp_enable_recolor(draw_dsc->recolor, draw_dsc->recolor_opa);
_lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, draw_dsc->opa,
draw_dsc->blend_mode);
lv_gpu_nxp_pxp_disable_recolor();
}
#endif
/*In the other cases every pixel need to be checked one-by-one*/
else {
/*The pixel size in byte is different if an alpha byte is added too*/
@@ -399,7 +419,8 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
return;
}
#endif
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area);
uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp);
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > (uint32_t) hor_res ? hor_res : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
@@ -449,7 +470,8 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
/*Most complicated case: transform or other mask or chroma keyed*/
else {
/*Build the image and a mask line-by-line*/
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area);
uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp);
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > hor_res ? hor_res : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);

View File

@@ -98,7 +98,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
dsc->font = LV_THEME_DEFAULT_FONT_NORMAL;
dsc->sel_start = LV_DRAW_LABEL_NO_TXT_SEL;
dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL;
dsc->sel_color = LV_COLOR_BLUE;
dsc->sel_color = LV_COLOR_BLACK;
dsc->sel_bg_color = LV_COLOR_BLUE;
dsc->bidi_dir = LV_BIDI_DIR_LTR;
}
@@ -234,7 +235,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
lv_draw_rect_dsc_t draw_dsc_sel;
lv_draw_rect_dsc_init(&draw_dsc_sel);
draw_dsc_sel.bg_color = dsc->sel_color;
draw_dsc_sel.bg_color = dsc->sel_bg_color;
int32_t pos_x_start = pos.x;
/*Write out all lines*/
@@ -320,6 +321,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
sel_coords.x2 = pos.x + letter_w + dsc->letter_space - 1;
sel_coords.y2 = pos.y + line_height - 1;
lv_draw_rect(&sel_coords, mask, &draw_dsc_sel);
color = dsc->sel_color;
}
}
@@ -522,7 +524,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
uint32_t col_bit;
col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */
uint32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : box_w * box_h;
lv_coord_t hor_res = lv_disp_get_hor_res(_lv_refr_get_disp_refreshing());
uint32_t mask_buf_size = box_w * box_h > hor_res ? hor_res : box_w * box_h;
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
int32_t mask_p = 0;

View File

@@ -29,6 +29,7 @@ extern "C" {
typedef struct {
lv_color_t color;
lv_color_t sel_color;
lv_color_t sel_bg_color;
const lv_font_t * font;
lv_opa_t opa;
lv_style_int_t line_space;

View File

@@ -424,7 +424,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
/*Draw the background line by line*/
int32_t h;
size_t mask_buf_size = LV_MATH_MIN(lv_area_get_size(&draw_area), LV_HOR_RES_MAX);
uint32_t hor_res = (uint32_t)lv_disp_get_hor_res(disp);
size_t mask_buf_size = LV_MATH_MIN(lv_area_get_size(&draw_area), hor_res);
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
lv_area_t fill_area;

View File

@@ -1,7 +1,3 @@
/**
* @file lv_mask.c
*

View File

@@ -51,7 +51,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
#endif
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
lv_coord_t radius, bool radius_is_in, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
/**********************
@@ -410,7 +410,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
area_inner.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout));
if(dsc->border_side == LV_BORDER_SIDE_FULL) {
draw_full_border(&area_inner, coords, clip, dsc->radius, dsc->border_color, dsc->border_opa, dsc->border_blend_mode);
draw_full_border(&area_inner, coords, clip, dsc->radius, false, dsc->border_color, dsc->border_opa,
dsc->border_blend_mode);
}
else {
lv_opa_t opa = dsc->border_opa;
@@ -1176,7 +1177,7 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const
area_outer.y1 -= dsc->outline_width;
area_outer.y2 += dsc->outline_width;
draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa,
draw_full_border(&area_inner, &area_outer, clip, dsc->radius, true, dsc->outline_color, dsc->outline_opa,
dsc->outline_blend_mode);
}
#endif
@@ -1325,7 +1326,7 @@ static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, con
#endif
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
lv_coord_t radius, bool radius_is_in, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
bool simple_mode = true;
@@ -1334,19 +1335,31 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
int32_t inner_w = lv_area_get_width(area_inner);
int32_t inner_h = lv_area_get_height(area_inner);
lv_coord_t border_width = area_outer->x2 - area_inner->x2;
int32_t rin = radius;
int32_t coords_out_w = lv_area_get_width(area_outer);
int32_t coords_out_h = lv_area_get_height(area_outer);
int32_t rin;
int32_t rout;
if(radius_is_in) {
rin = radius;
int32_t short_side = LV_MATH_MIN(inner_w, inner_h);
if(rin > short_side >> 1) rin = short_side >> 1;
/*Get the outer area*/
int32_t rout = rin + border_width;
int32_t coords_out_w = lv_area_get_width(area_outer);
int32_t coords_out_h = lv_area_get_height(area_outer);
short_side = LV_MATH_MIN(coords_out_w, coords_out_h);
rout = rin + border_width;
}
else {
rout = radius;
int32_t short_side = LV_MATH_MIN(coords_out_w, coords_out_h);
if(rout > short_side >> 1) rout = short_side >> 1;
/*Get the outer area*/
rin = rout - border_width;
if(rin < 0) rin = 0;
}
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);

View File

@@ -512,7 +512,7 @@ static bool lvgl_load_font(lv_fs_file_t * fp, lv_font_t * font)
font->line_height = font_header.ascent - font_header.descent;
font->get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt;
font->get_glyph_bitmap = lv_font_get_bitmap_fmt_txt;
font->subpx = LV_FONT_SUBPX_NONE;
font->subpx = font_header.subpixels_mode;
font_dsc->bpp = font_header.bits_per_pixel;
font_dsc->kern_scale = font_header.kerning_scale;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

480
src/lv_gpu/lv_gpu_nxp_pxp.c Normal file
View File

@@ -0,0 +1,480 @@
/**
* @file lv_gpu_nxp_pxp.c
*
*/
/**
* MIT License
*
* Copyright (c) 2020 NXP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if LV_USE_GPU_NXP_PXP
#include "lvgl.h"
#include "lv_gpu_nxp_pxp.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_log.h"
#include "fsl_pxp.h"
#include "fsl_cache.h"
/*********************
* DEFINES
*********************/
#if LV_COLOR_16_SWAP
#error Color swap not implemented. Disable LV_COLOR_16_SWAP feature.
#endif
#if LV_COLOR_DEPTH==16
#define PXP_OUT_PIXEL_FORMAT kPXP_OutputPixelFormatRGB565
#define PXP_AS_PIXEL_FORMAT kPXP_AsPixelFormatRGB565
#define PXP_PS_PIXEL_FORMAT kPXP_PsPixelFormatRGB565
#elif
#error Only 16bit color depth is supported. Set LV_COLOR_DEPTH to 16.
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_gpu_nxp_pxp_run(void);
static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width, const lv_color_t * src,
lv_coord_t src_width,
lv_coord_t copy_width, lv_coord_t copy_height, lv_opa_t opa, lv_color_t recolor, lv_opa_t recolorOpa);
static void lv_gpu_nxp_invalidate_cache(uint32_t address, uint32_t width, uint32_t height, uint32_t stride,
uint32_t pxSize);
/**********************
* STATIC VARIABLES
**********************/
static bool colorKeyEnabled = false;
static uint32_t colorKey = 0x0;
static bool recolorEnabled = false;
static lv_color_t recolor = {.full = 0x0};
static lv_opa_t recolorOpa = 0x0;
static lv_nxp_pxp_cfg_t pxp_cfg;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Reset and initialize PXP device. This function should be called as a part
* of display init sequence.
*
* @return LV_RES_OK: PXP init ok; LV_RES_INV: init error. See error log for more information.
*/
lv_res_t lv_gpu_nxp_pxp_init(lv_nxp_pxp_cfg_t * cfg)
{
if(!cfg || !cfg->pxp_interrupt_deinit || !cfg->pxp_interrupt_init || !cfg->pxp_run) {
LV_LOG_ERROR("PXP configuration error. Check callback pointers.");
return LV_RES_INV;
}
PXP_Init(PXP);
PXP_EnableCsc1(PXP, false); /* Disable CSC1, it is enabled by default. */
PXP_EnableInterrupts(PXP, kPXP_CompleteInterruptEnable);
pxp_cfg = *cfg;
if(pxp_cfg.pxp_interrupt_init() != LV_RES_OK) {
PXP_Deinit(PXP);
LV_LOG_ERROR("PXP interrupt init error. Check pxp_interrupt_init callback.");
return LV_RES_INV;
}
colorKey = lv_color_to32(LV_COLOR_TRANSP);
return LV_RES_OK;
}
/**
* Disable PXP device. Should be called during display deinit sequence.
*/
void lv_gpu_nxp_pxp_deinit(void)
{
pxp_cfg.pxp_interrupt_deinit();
PXP_DisableInterrupts(PXP, kPXP_CompleteInterruptEnable);
PXP_Deinit(LV_GPU_NXP_PXP_ID);
}
/**
* Fill area, with optional opacity.
*
* @param[in/out] dest_buf destination buffer
* @param[in] dest_width width (stride) of destination buffer in pixels
* @param[in] fill_area area to fill
* @param[in] color color
* @param[in] opa transparency of the color
*/
void lv_gpu_nxp_pxp_fill(lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color,
lv_opa_t opa)
{
PXP_Init(LV_GPU_NXP_PXP_ID);
PXP_EnableCsc1(LV_GPU_NXP_PXP_ID, false); /* Disable CSC1, it is enabled by default. */
PXP_SetProcessBlockSize(PXP, kPXP_BlockSize16); /* Block size 16x16 for higher performance */
/* OUT buffer configure */
pxp_output_buffer_config_t outputConfig = {
.pixelFormat = PXP_OUT_PIXEL_FORMAT,
.interlacedMode = kPXP_OutputProgressive,
.buffer0Addr = (uint32_t)(dest_buf + dest_width * fill_area->y1 + fill_area->x1),
.buffer1Addr = (uint32_t)NULL,
.pitchBytes = dest_width * sizeof(lv_color_t),
.width = fill_area->x2 - fill_area->x1 + 1,
.height = fill_area->y2 - fill_area->y1 + 1,
};
lv_gpu_nxp_invalidate_cache(outputConfig.buffer0Addr, outputConfig.width, outputConfig.height, outputConfig.pitchBytes,
sizeof(lv_color_t));
PXP_SetOutputBufferConfig(LV_GPU_NXP_PXP_ID, &outputConfig);
if(opa > LV_OPA_MAX) {
/* Simple color fill without opacity - AS disabled, PS as color generator */
PXP_SetAlphaSurfacePosition(LV_GPU_NXP_PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U); /* Disable AS. */
PXP_SetProcessSurfacePosition(LV_GPU_NXP_PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U); /* Disable PS. */
PXP_SetProcessSurfaceBackGroundColor(LV_GPU_NXP_PXP_ID, lv_color_to32(color));
}
else {
/* Fill with opacity - AS used as source (same as OUT), PS used as color generator, blended together */
pxp_as_buffer_config_t asBufferConfig;
pxp_porter_duff_config_t pdConfig;
/* Set AS to OUT */
asBufferConfig.pixelFormat = PXP_AS_PIXEL_FORMAT;
asBufferConfig.bufferAddr = (uint32_t)outputConfig.buffer0Addr;
asBufferConfig.pitchBytes = outputConfig.pitchBytes;
PXP_SetAlphaSurfaceBufferConfig(LV_GPU_NXP_PXP_ID, &asBufferConfig);
PXP_SetAlphaSurfacePosition(LV_GPU_NXP_PXP_ID, 0U, 0U, fill_area->x2 - fill_area->x1 + 1,
fill_area->y2 - fill_area->y1 + 1);
/* Disable PS, use as color generator */
PXP_SetProcessSurfacePosition(LV_GPU_NXP_PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U);
PXP_SetProcessSurfaceBackGroundColor(LV_GPU_NXP_PXP_ID, lv_color_to32(color));
/* Configure Porter-Duff blending - For RGB 565 only! */
pdConfig.enable = 1;
pdConfig.dstColorMode = kPXP_PorterDuffColorStraight;
pdConfig.srcColorMode = kPXP_PorterDuffColorStraight;
pdConfig.dstGlobalAlphaMode = kPXP_PorterDuffGlobalAlpha;
pdConfig.srcGlobalAlphaMode = kPXP_PorterDuffGlobalAlpha;
pdConfig.srcFactorMode = kPXP_PorterDuffFactorStraight;
pdConfig.dstFactorMode = kPXP_PorterDuffFactorStraight;
pdConfig.srcGlobalAlpha = opa;
pdConfig.dstGlobalAlpha = 255 - opa;
pdConfig.srcAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
pdConfig.dstAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
PXP_SetPorterDuffConfig(LV_GPU_NXP_PXP_ID, &pdConfig);
}
lv_gpu_nxp_pxp_run(); /* Start PXP task */
}
/**
* @brief BLock Image Transfer - copy rectangular image from src buffer to dst buffer with effects.
*
* By default, image is copied directly, with optional opacity configured by \p opa.
* Color keying can be enabled by calling lv_gpu_nxp_pxp_enable_color_key() before calling this function.
* Recoloring can be enabled by calling lv_gpu_nxp_pxp_enable_recolor() before calling this function.
* Note that color keying and recoloring at the same time is not supported and black rectangle is rendered.
*
* @param[in/out] dest destination buffer
* @param[in] dest_width width (stride) of destination buffer in pixels
* @param[in] src source buffer
* @param[in] src_with width (stride) of source buffer in pixels
* @param[in] copy_w width of area to be copied from src to dest
* @param[in] copy_h height of area to be copied from src to dest
* @param[in] opa opacity of the result
*/
void lv_gpu_nxp_pxp_blit(lv_color_t * dest, lv_coord_t dest_width, const lv_color_t * src, lv_coord_t src_width,
lv_coord_t copy_width, lv_coord_t copy_height, lv_opa_t opa)
{
if(recolorEnabled) { /* switch to recolor version of blit */
lv_gpu_nxp_pxp_blit_recolor(dest, dest_width, src, src_width, copy_width, copy_height, opa, recolor, recolorOpa);
return;
};
PXP_Init(PXP);
PXP_EnableCsc1(PXP, false); /* Disable CSC1, it is enabled by default. */
PXP_SetProcessBlockSize(PXP, kPXP_BlockSize16); /* block size 16x16 for higher performance */
pxp_output_buffer_config_t outputBufferConfig;
pxp_as_buffer_config_t asBufferConfig;
pxp_as_blend_config_t asBlendConfig;
asBlendConfig.alpha = opa;
asBlendConfig.invertAlpha = false;
asBlendConfig.alphaMode = kPXP_AlphaRop;
asBlendConfig.ropMode = kPXP_RopMergeAs;
if(opa >= LV_OPA_MAX && !colorKeyEnabled) {
/* Simple blit, no effect - Disable PS buffer */
PXP_SetProcessSurfacePosition(LV_GPU_NXP_PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U);
}
else {
/* Alpha blending or color keying enabled - PS must be enabled to fetch background pixels
PS and OUT buffers are the same, blend will be done in-place */
pxp_ps_buffer_config_t psBufferConfig = {
.pixelFormat = PXP_PS_PIXEL_FORMAT,
.swapByte = false,
.bufferAddr = (uint32_t)dest,
.bufferAddrU = 0U,
.bufferAddrV = 0U,
.pitchBytes = dest_width * sizeof(lv_color_t)
};
asBlendConfig.alphaMode = kPXP_AlphaOverride;
PXP_SetProcessSurfaceBufferConfig(LV_GPU_NXP_PXP_ID, &psBufferConfig);
PXP_SetProcessSurfacePosition(LV_GPU_NXP_PXP_ID, 0U, 0U, copy_width - 1, copy_height - 1);
}
/* AS buffer - source image */
asBufferConfig.pixelFormat = PXP_AS_PIXEL_FORMAT;
asBufferConfig.bufferAddr = (uint32_t)src;
asBufferConfig.pitchBytes = src_width * sizeof(lv_color_t);
PXP_SetAlphaSurfaceBufferConfig(LV_GPU_NXP_PXP_ID, &asBufferConfig);
PXP_SetAlphaSurfacePosition(LV_GPU_NXP_PXP_ID, 0U, 0U, copy_width - 1U, copy_height - 1U);
PXP_SetAlphaSurfaceBlendConfig(LV_GPU_NXP_PXP_ID, &asBlendConfig);
lv_gpu_nxp_invalidate_cache(asBufferConfig.bufferAddr, copy_width, copy_height, asBufferConfig.pitchBytes,
sizeof(lv_color_t));
if(colorKeyEnabled) {
PXP_SetAlphaSurfaceOverlayColorKey(LV_GPU_NXP_PXP_ID, colorKey, colorKey);
}
PXP_EnableAlphaSurfaceOverlayColorKey(LV_GPU_NXP_PXP_ID, colorKeyEnabled);
/* Output buffer. */
outputBufferConfig.pixelFormat = (pxp_output_pixel_format_t)PXP_OUT_PIXEL_FORMAT;
outputBufferConfig.interlacedMode = kPXP_OutputProgressive;
outputBufferConfig.buffer0Addr = (uint32_t)dest;
outputBufferConfig.buffer1Addr = (uint32_t)0U;
outputBufferConfig.pitchBytes = dest_width * sizeof(lv_color_t);
outputBufferConfig.width = copy_width;
outputBufferConfig.height = copy_height;
PXP_SetOutputBufferConfig(LV_GPU_NXP_PXP_ID, &outputBufferConfig);
lv_gpu_nxp_invalidate_cache(outputBufferConfig.buffer0Addr, outputBufferConfig.width, outputBufferConfig.height,
outputBufferConfig.pitchBytes, sizeof(lv_color_t));
lv_gpu_nxp_pxp_run(); /* Start PXP task */
}
/**
* @brief Enable color keying for subsequent calls to lv_gpu_nxp_pxp_blit()
*
* Color key is defined by LV_COLOR_TRANSP symbol in lv_conf.h
*/
void lv_gpu_nxp_pxp_enable_color_key(void)
{
colorKeyEnabled = true;
}
/**
* @brief Disable color keying for subsequent calls to lv_gpu_nxp_pxp_blit()
*
*/
void lv_gpu_nxp_pxp_disable_color_key(void)
{
colorKeyEnabled = false;
}
/**
* @brief Enable recolor feature for subsequent calls to lv_gpu_nxp_pxp_blit()
*
* @param[in] color recolor value
* @param[in] opa effect opacity
*/
void lv_gpu_nxp_pxp_enable_recolor(lv_color_t color, lv_opa_t opa)
{
recolorEnabled = true;
recolor = color;
recolorOpa = opa;
}
/**
* @brief Disable recolor feature for subsequent calls to lv_gpu_nxp_pxp_blit()
*/
void lv_gpu_nxp_pxp_disable_recolor(void)
{
recolorEnabled = false;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* @brief Start PXP job and wait for results
*
* Function used internally to start PXP task according current device
* configuration.
*/
static void lv_gpu_nxp_pxp_run(void)
{
pxp_cfg.pxp_run();
}
/**
* @brief BLock Image Transfer - copy rectangular image from src buffer to dst buffer with recoloring.
*
* Note that color keying and recoloring at the same time is not supported and black rectangle is rendered.
*
* @param[in/out] dest destination buffer
* @param[in] dest_width width (stride) of destination buffer in pixels
* @param[in] src source buffer
* @param[in] src_with width (stride) of source buffer in pixels
* @param[in] copy_w width of area to be copied from src to dest
* @param[in] copy_h height of area to be copied from src to dest
* @param[in] opa opacity of the result
* @param[in] recolor recolor value
* @param[in] recolorOpa effect opacity
*/
static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width, const lv_color_t * src,
lv_coord_t src_width,
lv_coord_t copy_width, lv_coord_t copy_height, lv_opa_t opa, lv_color_t recolor, lv_opa_t recolorOpa)
{
pxp_output_buffer_config_t outputBufferConfig;
pxp_as_buffer_config_t asBufferConfig;
if(colorKeyEnabled) {
/* should never get here, recolor & color keying not supported. Draw black box instead. */
const lv_area_t fill_area = {.x1 = 0, .y1 = 0, .x2 = copy_width - 1, .y2 = copy_height - 1};
lv_gpu_nxp_pxp_fill(dest, dest_width, &fill_area, LV_COLOR_BLACK, LV_OPA_MAX);
LV_LOG_WARN("Recoloring and color keying is not supported. Black rectangle rendered.");
return ;
}
else {
/* Recoloring without color keying */
if(opa > LV_OPA_MAX) {
/* Recolor with full opacity - AS source image, PS color generator, OUT destination */
PXP_Init(PXP);
PXP_EnableCsc1(PXP, false); /* Disable CSC1, it is enabled by default. */
PXP_SetProcessBlockSize(PXP, kPXP_BlockSize16); /* block size 16x16 for higher performance */
/* AS buffer - source image */
asBufferConfig.pixelFormat = PXP_AS_PIXEL_FORMAT;
asBufferConfig.bufferAddr = (uint32_t)src;
asBufferConfig.pitchBytes = src_width * sizeof(lv_color_t);
PXP_SetAlphaSurfaceBufferConfig(LV_GPU_NXP_PXP_ID, &asBufferConfig);
PXP_SetAlphaSurfacePosition(LV_GPU_NXP_PXP_ID, 0U, 0U, copy_width - 1U, copy_height - 1U);
lv_gpu_nxp_invalidate_cache(asBufferConfig.bufferAddr, copy_width, copy_height, asBufferConfig.pitchBytes,
sizeof(lv_color_t));
/* Disable PS buffer, use as color generator */
PXP_SetProcessSurfacePosition(LV_GPU_NXP_PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U);
PXP_SetProcessSurfaceBackGroundColor(LV_GPU_NXP_PXP_ID, lv_color_to32(recolor));
/* Output buffer */
outputBufferConfig.pixelFormat = (pxp_output_pixel_format_t)PXP_OUT_PIXEL_FORMAT;
outputBufferConfig.interlacedMode = kPXP_OutputProgressive;
outputBufferConfig.buffer0Addr = (uint32_t)dest;
outputBufferConfig.buffer1Addr = (uint32_t)0U;
outputBufferConfig.pitchBytes = dest_width * sizeof(lv_color_t);
outputBufferConfig.width = copy_width;
outputBufferConfig.height = copy_height;
PXP_SetOutputBufferConfig(LV_GPU_NXP_PXP_ID, &outputBufferConfig);
lv_gpu_nxp_invalidate_cache(outputBufferConfig.buffer0Addr, outputBufferConfig.width, outputBufferConfig.height,
outputBufferConfig.pitchBytes, sizeof(lv_color_t));
pxp_porter_duff_config_t pdConfig;
/* Configure Porter-Duff blending - For RGB 565 only! */
pdConfig.enable = 1;
pdConfig.dstColorMode = kPXP_PorterDuffColorStraight;
pdConfig.srcColorMode = kPXP_PorterDuffColorStraight;
pdConfig.dstGlobalAlphaMode = kPXP_PorterDuffGlobalAlpha;
pdConfig.srcGlobalAlphaMode = kPXP_PorterDuffGlobalAlpha;
pdConfig.srcFactorMode = kPXP_PorterDuffFactorStraight;
pdConfig.dstFactorMode = kPXP_PorterDuffFactorStraight;
pdConfig.srcGlobalAlpha = recolorOpa;
pdConfig.dstGlobalAlpha = 255 - recolorOpa;
pdConfig.srcAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
pdConfig.dstAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
PXP_SetPorterDuffConfig(LV_GPU_NXP_PXP_ID, &pdConfig);
lv_gpu_nxp_pxp_run(); /* Start PXP task */
}
else {
/* Recolor with transparency */
/* Step 1: Recolor with full opacity to temporary buffer */
lv_color_t * tmpBuf = (lv_color_t *) _lv_mem_buf_get(copy_width * copy_height * sizeof(lv_color_t));
lv_gpu_nxp_pxp_blit_recolor(tmpBuf, copy_width, src, src_width, copy_width, copy_height, LV_OPA_COVER, recolor,
recolorOpa);
/* Step 2: BLIT temporary results with required opacity to output */
lv_gpu_nxp_pxp_disable_recolor(); /* make sure to take BLIT path, not the recolor */
lv_gpu_nxp_pxp_blit(dest, dest_width, tmpBuf, copy_width, copy_width, copy_height, opa);
lv_gpu_nxp_pxp_enable_recolor(recolor, recolorOpa); /* restore state */
/* Step 3: Clean-up memory */
_lv_mem_buf_release(tmpBuf);
}
}
}
/**
* @brief Invalidate cache for rectangular area of memory
*
* @param[in] address starting address of area
* @param[in] width width of area in pixels
* @param[in] height height of area in pixels
* @param[in] stride stride in bytes
* @param[in] pxSize pixel size in bytes
*/
static void lv_gpu_nxp_invalidate_cache(uint32_t address, uint32_t width, uint32_t height, uint32_t stride,
uint32_t pxSize)
{
int y;
for(y = 0; y < height; y++) {
DCACHE_CleanInvalidateByRange(address, width * pxSize);
address += stride;
}
}
#endif /* LV_USE_GPU && LV_USE_GPU_NXP_PXP */

186
src/lv_gpu/lv_gpu_nxp_pxp.h Normal file
View File

@@ -0,0 +1,186 @@
/**
* @file lv_gpu_nxp_pxp.h
*
*/
/**
* MIT License
*
* Copyright (c) 2020 NXP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef LV_SRC_LV_GPU_LV_GPU_NXP_PXP_H_
#define LV_SRC_LV_GPU_LV_GPU_NXP_PXP_H_
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_color.h"
/*********************
* DEFINES
*********************/
/** PXP module instance to use */
#define LV_GPU_NXP_PXP_ID PXP
/** PXP interrupt line ID */
#define LV_GPU_NXP_PXP_IRQ_ID PXP_IRQn
#ifndef LV_GPU_NXP_PXP_BLIT_SIZE_LIMIT
/** Minimum area (in pixels) for image copy with 100% opacity to be handled by PXP */
#define LV_GPU_NXP_PXP_BLIT_SIZE_LIMIT 32
#endif
#ifndef LV_GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT
/** Minimum area (in pixels) for image copy with transparency to be handled by PXP */
#define LV_GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT 16
#endif
#ifndef LV_GPU_NXP_PXP_FILL_SIZE_LIMIT
/** Minimum area (in pixels) to be filled by PXP with 100% opacity */
#define LV_GPU_NXP_PXP_FILL_SIZE_LIMIT 64
#endif
#ifndef LV_GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT
/** Minimum area (in pixels) to be filled by PXP with transparency */
#define LV_GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT 32
#endif
/**********************
* TYPEDEFS
**********************/
/**
* NXP PXP device configuration - call-backs used for
* interrupt init/wait/deinit.
*/
typedef struct {
/** Callback for PXP interrupt initialization */
lv_res_t (*pxp_interrupt_init)(void);
/** Callback for PXP interrupt de-initialization */
void (*pxp_interrupt_deinit)(void);
/** Callback that should start PXP and wait for operation complete */
void (*pxp_run)(void);
} lv_nxp_pxp_cfg_t;
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Reset and initialize PXP device. This function should be called as a part
* of display init sequence.
*
* @return LV_RES_OK: PXP init ok; LV_RES_INV: init error. See error log for more information.
*/
lv_res_t lv_gpu_nxp_pxp_init(lv_nxp_pxp_cfg_t * cfg);
/**
* Disable PXP device. Should be called during display deinit sequence.
*/
void lv_gpu_nxp_pxp_deinit(void);
/**
* Fill area, with optional opacity.
*
* @param[in/out] dest_buf destination buffer
* @param[in] dest_width width (stride) of destination buffer in pixels
* @param[in] fill_area area to fill
* @param[in] color color
* @param[in] opa transparency of the color
*/
void lv_gpu_nxp_pxp_fill(lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color,
lv_opa_t opa);
/**
* @brief BLock Image Transfer - copy rectangular image from src buffer to dst buffer with effects.
*
* By default, image is copied directly, with optional opacity configured by \p opa.
* Color keying can be enabled by calling lv_gpu_nxp_pxp_enable_color_key() before calling this function.
* Recoloring can be enabled by calling lv_gpu_nxp_pxp_enable_recolor() before calling this function.
* Note that color keying and recoloring at the same time is not supported and black rectangle is rendered.
*
* @param[in/out] dest destination buffer
* @param[in] dest_width width (stride) of destination buffer in pixels
* @param[in] src source buffer
* @param[in] src_with width (stride) of source buffer in pixels
* @param[in] copy_w width of area to be copied from src to dest
* @param[in] copy_h height of area to be copied from src to dest
* @param[in] opa opacity of the result
*/
void lv_gpu_nxp_pxp_blit(lv_color_t * dest, lv_coord_t dest_width, const lv_color_t * src, lv_coord_t src_width,
lv_coord_t copy_width, lv_coord_t copy_height, lv_opa_t opa);
/**
* @brief Enable color keying for subsequent calls to lv_gpu_nxp_pxp_blit()
*
* Color key is defined by LV_COLOR_TRANSP symbol in lv_conf.h
*/
void lv_gpu_nxp_pxp_enable_color_key(void);
/**
* @brief Disable color keying for subsequent calls to lv_gpu_nxp_pxp_blit()
*
*/
void lv_gpu_nxp_pxp_disable_color_key(void);
/**
* @brief Enable recolor feature for subsequent calls to lv_gpu_nxp_pxp_blit()
*
* @param[in] color recolor value
* @param[in] opa effect opacity
*/
void lv_gpu_nxp_pxp_enable_recolor(lv_color_t color, lv_opa_t opa);
/**
* @brief Disable recolor feature for subsequent calls to lv_gpu_nxp_pxp_blit()
*/
void lv_gpu_nxp_pxp_disable_recolor(void);
/**********************
* STATIC FUNCTIONS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LV_SRC_LV_GPU_LV_GPU_NXP_PXP_H_ */

View File

@@ -0,0 +1,166 @@
/**
* @file lv_gpu_nxp_pxp_osa.c
*
*/
/**
* MIT License
*
* Copyright (c) 2020 NXP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
#include "lv_gpu_nxp_pxp.h"
#include "fsl_pxp.h"
#if defined(FSL_RTOS_FREE_RTOS)
#include "FreeRTOS.h"
#include "semphr.h"
#endif
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t _lv_gpu_nxp_pxp_interrupt_init(void);
static void _lv_gpu_nxp_pxp_interrupt_deinit(void);
static void _lv_gpu_nxp_pxp_run(void);
/**********************
* STATIC VARIABLES
**********************/
#if defined(FSL_RTOS_FREE_RTOS)
static SemaphoreHandle_t s_pxpIdle;
#else
static volatile bool s_pxpIdle;
#endif
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* PXP device interrupt handler. Used to check PXP task completion status.
*/
void PXP_IRQHandler(void)
{
#if defined(FSL_RTOS_FREE_RTOS)
BaseType_t taskAwake = pdFALSE;
#endif
if(kPXP_CompleteFlag & PXP_GetStatusFlags(LV_GPU_NXP_PXP_ID)) {
PXP_ClearStatusFlags(LV_GPU_NXP_PXP_ID, kPXP_CompleteFlag);
#if defined(FSL_RTOS_FREE_RTOS)
xSemaphoreGiveFromISR(s_pxpIdle, &taskAwake);
portYIELD_FROM_ISR(taskAwake);
#else
s_pxpIdle = true;
#endif
}
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* PXP interrupt initialization.
*/
static lv_res_t _lv_gpu_nxp_pxp_interrupt_init(void)
{
#if defined(FSL_RTOS_FREE_RTOS)
s_pxpIdle = xSemaphoreCreateBinary();
if(s_pxpIdle == NULL) {
return LV_RES_INV;
}
NVIC_SetPriority(LV_GPU_NXP_PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1);
#else
s_pxpIdle = true;
#endif
NVIC_EnableIRQ(LV_GPU_NXP_PXP_IRQ_ID);
return LV_RES_OK;
}
/**
* PXP interrupt de-initialization.
*/
static void _lv_gpu_nxp_pxp_interrupt_deinit(void)
{
NVIC_DisableIRQ(LV_GPU_NXP_PXP_IRQ_ID);
#if defined(FSL_RTOS_FREE_RTOS)
vSemaphoreDelete(s_pxpIdle);
#endif
}
/**
* Function to start PXP job. This function must wait for task complete.
*/
static void _lv_gpu_nxp_pxp_run(void)
{
#if !defined(FSL_RTOS_FREE_RTOS)
s_pxpIdle = false;
#endif
PXP_EnableInterrupts(LV_GPU_NXP_PXP_ID, kPXP_CompleteInterruptEnable);
PXP_Start(LV_GPU_NXP_PXP_ID);
#if defined(FSL_RTOS_FREE_RTOS)
if(xSemaphoreTake(s_pxpIdle, portMAX_DELAY) != pdTRUE) {
LV_LOG_ERROR("xSemaphoreTake error. Task halted.");
for(; ;) ;
}
#else
while(s_pxpIdle == false) {
}
#endif
}
lv_nxp_pxp_cfg_t pxp_default_cfg = {
.pxp_interrupt_init = _lv_gpu_nxp_pxp_interrupt_init,
.pxp_interrupt_deinit = _lv_gpu_nxp_pxp_interrupt_deinit,
.pxp_run = _lv_gpu_nxp_pxp_run
};
#endif /* LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT */

View File

@@ -0,0 +1,47 @@
/**
* @file lv_gpu_nxp_pxp_osa.h
*
*/
/**
* MIT License
*
* Copyright (c) 2020 NXP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_
#define LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "lv_conf.h"
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
extern lv_nxp_pxp_cfg_t pxp_default_cfg;
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_ */

View File

@@ -0,0 +1,303 @@
/**
* @file lv_gpu_nxp_vglite.c
*
*/
/**
* MIT License
*
* Copyright (c) 2020 NXP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if LV_USE_GPU_NXP_VG_LITE
#include "lvgl.h"
#include "lv_gpu_nxp_vglite.h"
#include "../lv_misc/lv_log.h"
#include "fsl_cache.h"
#include "vg_lite.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
#if LV_COLOR_DEPTH==16
#define VGLITE_PX_FMT VG_LITE_RGB565
#else
#error Only 16bit color depth is supported. Set LV_COLOR_DEPTH to 16.
#endif
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t init_vg_buf(vg_lite_buffer_t * dst, uint32_t width, uint32_t height, uint32_t stride,
const lv_color_t * ptr);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/***
* Fills rectangular area in buffer.
* @param[in] dest_buf Destination buffer pointer (must be aligned on 32 bytes)
* @param[in] dest_width Destination buffer width in pixels (must be aligned on 16 px)
* @param[in] dest_height Destination buffer height in pixels
* @param[in] fill_area Area to be filled
* @param[in] color Fill color
* @param[in] opa Opacity (255 = full, 128 = 50% background/50% color, 0 = no fill)
* @retval LV_RES_OK Fill completed
* @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
*/
lv_res_t lv_gpu_nxp_vglite_fill(lv_color_t * dest_buf, lv_coord_t dest_width, lv_coord_t dest_height,
const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa)
{
vg_lite_buffer_t rt;
vg_lite_rectangle_t rect;
vg_lite_error_t err = VG_LITE_SUCCESS;
lv_color32_t col32 = {.full = lv_color_to32(color)}; /* Convert color to RGBA8888 */
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
if(init_vg_buf(&rt, dest_width, dest_height, dest_width * sizeof(lv_color_t), dest_buf) != LV_RES_OK) {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("init_vg_buf reported error. Fill failed.");
#endif
return LV_RES_INV;
}
if(opa >= LV_OPA_MAX) { /* Opaque fill */
rect.x = fill_area->x1;
rect.y = fill_area->y1;
rect.width = (fill_area->x2 - fill_area->x1) + 1;
rect.height = (fill_area->y2 - fill_area->y1) + 1;
if(disp && disp->driver.clean_dcache_cb) { /* Clean & invalidate cache */
disp->driver.clean_dcache_cb(&disp->driver);
}
err |= vg_lite_clear(&rt, &rect, col32.full);
err |= vg_lite_finish();
}
else { /* fill with transparency */
vg_lite_path_t path;
lv_color32_t colMix;
int16_t path_data[] = { /* VG rectangular path */
VLC_OP_MOVE, fill_area->x1, fill_area->y1,
VLC_OP_LINE, fill_area->x2 + 1, fill_area->y1,
VLC_OP_LINE, fill_area->x2 + 1, fill_area->y2 + 1,
VLC_OP_LINE, fill_area->x1, fill_area->y2 + 1,
VLC_OP_LINE, fill_area->x1, fill_area->y1,
VLC_OP_END
};
err |= vg_lite_init_path(&path, VG_LITE_S16, VG_LITE_LOW, sizeof(path_data), path_data,
fill_area->x1, fill_area->y1, fill_area->x2 + 1, fill_area->y2 + 1);
if(err != VG_LITE_SUCCESS) {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("vg_lite_init_path() failed.");
#endif
return LV_RES_INV;
}
colMix.ch.red = ((uint16_t)col32.ch.red * opa) >> 8; /* Pre-multiply color */
colMix.ch.green = ((uint16_t)col32.ch.green * opa) >> 8;
colMix.ch.blue = ((uint16_t)col32.ch.blue * opa) >> 8;
colMix.ch.alpha = opa;
if(disp && disp->driver.clean_dcache_cb) { /* Clean & invalidate cache */
disp->driver.clean_dcache_cb(&disp->driver);
}
vg_lite_matrix_t matrix;
vg_lite_identity(&matrix);
/* Draw rectangle */
err |= vg_lite_draw(&rt, &path, VG_LITE_FILL_EVEN_ODD, &matrix, VG_LITE_BLEND_SRC_OVER, colMix.full);
if(err) {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("vg_lite_draw() failed.");
#endif
vg_lite_clear_path(&path);
return LV_RES_INV;
}
err |= vg_lite_finish();
err |= vg_lite_clear_path(&path);
}
if(err == VG_LITE_SUCCESS) {
return LV_RES_OK;
}
else {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("VG Lite Fill failed.");
#endif
return LV_RES_INV;
}
}
/***
* BLock Image Transfer.
* @param[in] blit Description of the transfer
* @retval LV_RES_OK Transfer complete
* @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
*/
lv_res_t lv_gpu_nxp_vglite_blit(lv_gpu_nxp_vglite_blit_info_t * blit)
{
vg_lite_buffer_t src_vgbuf, dst_vgbuf;
vg_lite_error_t err = VG_LITE_SUCCESS;
uint32_t rect[4];
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
if(blit->opa < LV_OPA_MIN) {
return LV_RES_OK; /* Nothing to BLIT */
}
if(!blit) {
/* Wrong parameter */
return LV_RES_INV;
}
/* Wrap src/dst buffer into VG-Lite buffer */
if(init_vg_buf(&src_vgbuf, blit->src_width, blit->src_height, blit->src_stride, blit->src) != LV_RES_OK) {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("init_vg_buf reported error. BLIT failed.");
#endif
return LV_RES_INV;
}
if(init_vg_buf(&dst_vgbuf, blit->dst_width, blit->dst_height, blit->dst_stride, blit->dst) != LV_RES_OK) {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("init_vg_buf reported error. BLIT failed.");
#endif
return LV_RES_INV;
}
rect[0] = 0; /* Crop */
rect[1] = 0;
rect[2] = blit->src_width;
rect[3] = blit->src_height;
vg_lite_matrix_t matrix;
vg_lite_identity(&matrix);
vg_lite_translate(blit->dst_area.x1, blit->dst_area.y1, &matrix);
if(disp && disp->driver.clean_dcache_cb) { /* Clean & invalidate cache */
disp->driver.clean_dcache_cb(&disp->driver);
}
uint32_t color;
vg_lite_blend_t blend;
if(blit->opa >= LV_OPA_MAX) {
color = 0x0;
blend = VG_LITE_BLEND_NONE;
}
else {
color = ((blit->opa) << 24) | ((blit->opa) << 16) | ((blit->opa) << 8) | (blit->opa);
blend = VG_LITE_BLEND_SRC_OVER;
src_vgbuf.image_mode = VG_LITE_MULTIPLY_IMAGE_MODE;
}
err |= vg_lite_blit_rect(&dst_vgbuf, &src_vgbuf, rect, &matrix, blend, color, VG_LITE_FILTER_POINT);
err |= vg_lite_finish();
if(err == VG_LITE_SUCCESS) {
return LV_RES_OK;
}
else {
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("vg_lite_blit_rect or vg_lite_finish reported error. BLIT failed.");
#endif
return LV_RES_INV;
}
}
/**********************
* STATIC FUNCTIONS
**********************/
/***
* Fills vg_lite_buffer_t structure according given parameters.
* @param[out] dst Buffer structure to be filled
* @param[in] width Width of buffer in pixels
* @param[in] height Height of buffer in pixels
* @param[in] stride Stride of the buffer in bytes
* @param[in] ptr Pointer to the buffer (must be aligned according VG-Lite requirements)
*/
static lv_res_t init_vg_buf(vg_lite_buffer_t * dst, uint32_t width, uint32_t height, uint32_t stride,
const lv_color_t * ptr)
{
if((((uintptr_t)ptr) % LV_ATTRIBUTE_MEM_ALIGN_SIZE) != 0x0) { /* Test for alignment */
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("ptr (0x%X) not aligned to %d.", (size_t) ptr, LV_ATTRIBUTE_MEM_ALIGN_SIZE);
#endif
return LV_RES_INV;
}
if((stride % LV_GPU_NXP_VG_LITE_STRIDE_ALIGN_PX) != 0x0) { /* Test for stride alignment */
#if LV_GPU_NXP_VG_LITE_LOG_ERRORS
LV_LOG_ERROR("Buffer stride (%d px) not aligned to %d px.", stride, LV_GPU_NXP_VG_LITE_STRIDE_ALIGN_PX);
#endif
return LV_RES_INV;
}
dst->format = VGLITE_PX_FMT;
dst->tiled = VG_LITE_LINEAR;
dst->image_mode = VG_LITE_NORMAL_IMAGE_MODE;
dst->transparency_mode = VG_LITE_IMAGE_OPAQUE;
dst->width = width;
dst->height = height;
dst->stride = stride;
memset(&dst->yuv, 0, sizeof(dst->yuv));
dst->memory = (void *) ptr;
dst->address = (uint32_t) dst->memory;
dst->handle = 0x0;
return LV_RES_OK;
}
#endif /* LV_USE_GPU_NXP_VG_LITE */

View File

@@ -0,0 +1,133 @@
/**
* @file lv_gpu_nxp_vglite.h
*
*/
/**
* MIT License
*
* Copyright (c) 2020 NXP
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef LV_SRC_LV_GPU_LV_GPU_NXP_VGLITE_H_
#define LV_SRC_LV_GPU_LV_GPU_NXP_VGLITE_H_
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_misc/lv_area.h"
/*********************
* DEFINES
*********************/
/** Stride in px required by VG-Lite HW. Don't change this. */
#define LV_GPU_NXP_VG_LITE_STRIDE_ALIGN_PX 16
#ifndef LV_GPU_NXP_VG_LITE_FILL_SIZE_LIMIT
/** Minimum area (in pixels) to be filled by VG-Lite with 100% opacity */
#define LV_GPU_NXP_VG_LITE_FILL_SIZE_LIMIT 32
#endif
#ifndef LV_GPU_NXP_VG_LITE_FILL_OPA_SIZE_LIMIT
/** Minimum area (in pixels) to be filled by VG-Lite with transparency */
#define LV_GPU_NXP_VG_LITE_FILL_OPA_SIZE_LIMIT 32
#endif
#ifndef LV_GPU_NXP_VG_LITE_BLIT_SIZE_LIMIT
/** Minimum area (in pixels) for image copy with 100% opacity to be handled by VG-Lite */
#define LV_GPU_NXP_VG_LITE_BLIT_SIZE_LIMIT 32
#endif
#ifndef LV_GPU_NXP_VG_LITE_BLIT_OPA_SIZE_LIMIT
/** Minimum area (in pixels) for image copy with transparency to be handled by VG-Lite */
#define LV_GPU_NXP_VG_LITE_BLIT_OPA_SIZE_LIMIT 32
#endif
#ifndef LV_GPU_NXP_VG_LITE_LOG_ERRORS
/** Enable logging of VG-Lite erors (\see LV_LOG_ERROR) */
#define LV_GPU_NXP_VG_LITE_LOG_ERRORS 1
#endif
/**********************
* TYPEDEFS
**********************/
/**
* BLock Image Transfer descriptor structure
*/
typedef struct {
const lv_color_t * src; /**< Source buffer pointer (must be aligned on 32 bytes) */
lv_area_t src_area; /**< Area to be copied from source */
lv_coord_t src_width; /**< Source buffer width */
lv_coord_t src_height; /**< Source buffer height */
uint32_t src_stride; /**< Source buffer stride in bytes (must be aligned on 16 px) */
const lv_color_t * dst; /**< Destination buffer pointer (must be aligned on 32 bytes) */
lv_area_t dst_area; /**< Target area in destination buffer (must be the same as src_area) */
lv_coord_t dst_width; /**< Destination buffer width */
lv_coord_t dst_height; /**< Destination buffer height */
uint32_t dst_stride; /**< Destination buffer stride in bytes (must be aligned on 16 px) */
lv_opa_t opa; /**< Opacity - alpha mix (0 = source not copied, 255 = 100% opaque) */
} lv_gpu_nxp_vglite_blit_info_t;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/***
* Fills rectangular area in buffer.
* @param[in] dest_buf Destination buffer pointer (must be aligned on 32 bytes)
* @param[in] dest_width Destination buffer width in pixels ((must be aligned on 16 px)
* @param[in] dest_height Destination buffer height in pixels
* @param[in] fill_area Area to be filled
* @param[in] color Fill color
* @param[in] opa Opacity (255 = full, 128 = 50% background/50% color, 0 = no fill)
* @retval LV_RES_OK Fill completed
* @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
*/
lv_res_t lv_gpu_nxp_vglite_fill(lv_color_t * dest_buf, lv_coord_t dest_width, lv_coord_t dest_height,
const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa);
/***
* BLock Image Transfer.
* @param[in] blit Description of the transfer
* @retval LV_RES_OK Transfer complete
* @retval LV_RES_INV Error occurred (\see LV_GPU_NXP_VG_LITE_LOG_ERRORS)
*/
lv_res_t lv_gpu_nxp_vglite_blit(lv_gpu_nxp_vglite_blit_info_t * blit);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LV_SRC_LV_GPU_LV_GPU_NXP_VGLITE_H_ */

View File

@@ -63,7 +63,16 @@ static void dma2d_wait(void);
void lv_gpu_stm32_dma2d_init(void)
{
/* Enable DMA2D clock */
#if defined(STM32F4) || defined(STM32F7)
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
#elif defined(STM32H7)
RCC->AHB3ENR |= RCC_AHB3ENR_DMA2DEN;
#else
# warning "LVGL can't enable the clock of DMA2D"
#endif
/* Wait for hardware access to complete */
__asm volatile("DSB\n");
/* Delay after setting peripheral clock */
volatile uint32_t temp = RCC->AHB1ENR;

View File

@@ -213,12 +213,12 @@ enum {
**********************/
typedef union {
uint8_t full; /*must be declared first to set all bits of byte via initializer list */
union {
uint8_t blue : 1;
uint8_t green : 1;
uint8_t red : 1;
} ch;
uint8_t full;
} lv_color1_t;
typedef union {
@@ -259,15 +259,19 @@ typedef union {
#if LV_COLOR_DEPTH == 1
typedef uint8_t lv_color_int_t;
typedef lv_color1_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {0x00}
#elif LV_COLOR_DEPTH == 8
typedef uint8_t lv_color_int_t;
typedef lv_color8_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00}}
#elif LV_COLOR_DEPTH == 16
typedef uint16_t lv_color_int_t;
typedef lv_color16_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00}}
#elif LV_COLOR_DEPTH == 32
typedef uint32_t lv_color_int_t;
typedef lv_color32_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00, 0x00}}
#else
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
@@ -553,9 +557,9 @@ LV_ATTRIBUTE_FAST_MEM static inline void lv_color_mix_with_alpha(lv_color_t bg_c
/*Save the parameters and the result. If they will be asked again don't compute again*/
static lv_opa_t fg_opa_save = 0;
static lv_opa_t bg_opa_save = 0;
static lv_color_t fg_color_save = {.full = 0};
static lv_color_t bg_color_save = {.full = 0};
static lv_color_t res_color_saved = {.full = 0};
static lv_color_t fg_color_save = _LV_COLOR_ZERO_INITIALIZER;
static lv_color_t bg_color_save = _LV_COLOR_ZERO_INITIALIZER;
static lv_color_t res_color_saved = _LV_COLOR_ZERO_INITIALIZER;
static lv_opa_t res_opa_saved = 0;
if(fg_opa != fg_opa_save || bg_opa != bg_opa_save || fg_color.full != fg_color_save.full ||
@@ -600,7 +604,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
/**
* MSVC compiler's definition of the __cplusplus indicating 199711L regardless to C++ standard version
* see https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-cplusplus
* so we use _MSC_VER macro unstead of __cplusplus
* so we use _MSC_VER macro instead of __cplusplus
*/
#ifdef _MSC_VER
#if _MSC_VER >= 1900 /* Visual Studio 2015 */
@@ -626,7 +630,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
/* The most simple macro to create a color from R,G and B values */
#if LV_COLOR_DEPTH == 1
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{(uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#elif LV_COLOR_DEPTH == 8
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}})
#elif LV_COLOR_DEPTH == 16

View File

@@ -81,7 +81,7 @@ void lv_debug_log_error(const char * msg, uint64_t value);
# define LV_ASSERT_NULL(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "NULL pointer", p);
# endif
#else
# define LV_ASSERT_NULL(p) true
# define LV_ASSERT_NULL(p)
#endif
#if LV_USE_ASSERT_MEM
@@ -89,7 +89,7 @@ void lv_debug_log_error(const char * msg, uint64_t value);
# define LV_ASSERT_MEM(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "Out of memory", p);
# endif
#else
# define LV_ASSERT_MEM(p) true
# define LV_ASSERT_MEM(p)
#endif
#if LV_USE_ASSERT_MEM_INTEGRITY
@@ -97,7 +97,7 @@ void lv_debug_log_error(const char * msg, uint64_t value);
# define LV_ASSERT_MEM_INTEGRITY() LV_DEBUG_ASSERT(LV_DEBUG_CHECK_MEM_INTEGRITY(), "Memory integrity error", 0);
# endif
#else
# define LV_ASSERT_MEM_INTEGRITY() true
# define LV_ASSERT_MEM_INTEGRITY()
#endif
#if LV_USE_ASSERT_STR
@@ -108,7 +108,7 @@ void lv_debug_log_error(const char * msg, uint64_t value);
# if LV_USE_ASSERT_NULL /*Use at least LV_ASSERT_NULL if enabled*/
# define LV_ASSERT_STR(str) LV_ASSERT_NULL(str)
# else
# define LV_ASSERT_STR(str) true
# define LV_ASSERT_STR(str)
# endif
#endif
@@ -117,11 +117,11 @@ void lv_debug_log_error(const char * msg, uint64_t value);
#define LV_DEBUG_ASSERT(expr, msg, value) do{}while(0)
#define LV_ASSERT_NULL(p) true
#define LV_ASSERT_MEM(p) true
#define LV_ASSERT_MEM_INTEGRITY() true
#define LV_ASSERT_STR(p) true
#define LV_ASSERT_OBJ(obj, obj_type) true
#define LV_ASSERT_NULL(p)
#define LV_ASSERT_MEM(p)
#define LV_ASSERT_MEM_INTEGRITY()
#define LV_ASSERT_STR(p)
#define LV_ASSERT_OBJ(obj, obj_type)
#endif /* LV_USE_DEBUG */
/*clang-format on*/

View File

@@ -79,75 +79,42 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_TRACE
#define LV_LOG_TRACE(...) _lv_log_add(LV_LOG_LEVEL_TRACE, __FILE__, __LINE__, __func__, __VA_ARGS__);
#else
#define LV_LOG_TRACE(...) \
{ \
; \
}
#define LV_LOG_TRACE(...)
#endif
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO
#define LV_LOG_INFO(...) _lv_log_add(LV_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__);
#else
#define LV_LOG_INFO(...) \
{ \
; \
}
#define LV_LOG_INFO(...)
#endif
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_WARN
#define LV_LOG_WARN(...) _lv_log_add(LV_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__);
#else
#define LV_LOG_WARN(...) \
{ \
; \
}
#define LV_LOG_WARN(...)
#endif
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_ERROR
#define LV_LOG_ERROR(...) _lv_log_add(LV_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__);
#else
#define LV_LOG_ERROR(...) \
{ \
; \
}
#define LV_LOG_ERROR(...)
#endif
#if LV_LOG_LEVEL <= LV_LOG_LEVEL_USER
#define LV_LOG_USER(...) _lv_log_add(LV_LOG_LEVEL_USER, __FILE__, __LINE__, __func__, __VA_ARGS__);
#else
#define LV_LOG_USER(...) \
{ \
; \
}
#define LV_LOG_USER(...)
#endif
#else /*LV_USE_LOG*/
/*Do nothing if `LV_USE_LOG 0`*/
#define _lv_log_add(level, file, line, ...) \
{ \
; \
}
#define LV_LOG_TRACE(...) \
{ \
; \
}
#define LV_LOG_INFO(...) \
{ \
; \
}
#define LV_LOG_WARN(...) \
{ \
; \
}
#define LV_LOG_ERROR(...) \
{ \
; \
}
#define LV_LOG_USER(...) \
{ \
; \
}
#define _lv_log_add(level, file, line, ...)
#define LV_LOG_TRACE(...)
#define LV_LOG_INFO(...)
#define LV_LOG_WARN(...)
#define LV_LOG_ERROR(...)
#define LV_LOG_USER(...)
#endif /*LV_USE_LOG*/
#ifdef __cplusplus

View File

@@ -42,8 +42,6 @@ extern "C" {
#define LV_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers) */
#define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/
/**********************
* TYPEDEFS
**********************/

View File

@@ -18,7 +18,7 @@ extern "C" {
* DEFINES
*********************/
#if __STDC_VERSION__ >= 199901L // If c99 or newer, use stdint.h to determine arch size
#if defined(__cplusplus) || __STDC_VERSION__ >= 199901L // If c99 or newer, use stdint.h to determine arch size
#include <stdint.h>
#endif
@@ -53,7 +53,7 @@ typedef uint8_t lv_res_t;
#if __STDC_VERSION__ >= 199901L
#if defined(__cplusplus) || __STDC_VERSION__ >= 199901L
// If c99 or newer, use the definition of uintptr_t directly from <stdint.h>
typedef uintptr_t lv_uintptr_t;

View File

@@ -64,7 +64,7 @@
#define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad))
#define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad))
#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150)
#define TRANSITION_TIME 0/*((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150)*/
#define BORDER_WIDTH LV_DPX(2)
#define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2))
#define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT)
@@ -204,7 +204,8 @@ static void basic_init(void)
lv_style_set_bg_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR);
lv_style_set_text_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
lv_style_set_value_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
lv_style_set_text_font(&styles->scr, LV_STATE_DEFAULT, theme.font_normal);
lv_style_set_text_sel_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
lv_style_set_text_sel_bg_color(&styles->scr, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_value_font(&styles->scr, LV_STATE_DEFAULT, theme.font_normal);
style_init_reset(&styles->bg);
@@ -217,7 +218,6 @@ static void basic_init(void)
lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true);
lv_style_set_text_font(&styles->bg, LV_STATE_DEFAULT, theme.font_normal);
lv_style_set_text_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
lv_style_set_value_font(&styles->bg, LV_STATE_DEFAULT, theme.font_normal);
lv_style_set_value_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
@@ -549,10 +549,12 @@ static void calendar_init(void)
#if LV_USE_CALENDAR
style_init_reset(&styles->calendar_header);
lv_style_set_pad_top(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_top(&styles->calendar_header, LV_STATE_DEFAULT, 0);
lv_style_set_pad_left(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->calendar_header, LV_STATE_DEFAULT, 0);
lv_style_set_margin_top(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_margin_bottom(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_text_color(&styles->calendar_header, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x888888) : LV_COLOR_WHITE);
style_init_reset(&styles->calendar_daynames);
@@ -847,7 +849,6 @@ static void tabview_win_shared_init(void)
lv_style_set_border_width(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(5));
lv_style_set_border_side(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM);
lv_style_set_text_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
lv_style_set_text_font(&styles->tabview_btns_bg, LV_STATE_DEFAULT, theme.font_normal);
lv_style_set_image_recolor(&styles->tabview_btns_bg, LV_STATE_DEFAULT, lv_color_hex(0x979a9f));
lv_style_set_pad_top(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
lv_style_set_pad_left(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
@@ -1255,27 +1256,28 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
_lv_style_list_add_style(list, &styles->pad_small);
_lv_style_list_add_style(list, &styles->chart_series_bg);
list = lv_obj_get_style_list(obj, LV_CHART_PART_CURSOR);
_lv_style_list_add_style(list, &styles->chart_series_bg);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
_lv_style_list_add_style(list, &styles->chart_series);
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
case LV_THEME_TABLE: {
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
_lv_style_list_add_style(list, &styles->table_cell);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
_lv_style_list_add_style(list, &styles->table_cell);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
_lv_style_list_add_style(list, &styles->table_cell);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
int idx = 1; /* start value should be 1, not zero, since cell styles
start at 1 due to presence of LV_TABLE_PART_BG=0
in the enum (lv_table.h) */
/* declaring idx outside loop to work with older compilers */
for(; idx <= LV_TABLE_CELL_STYLE_CNT; idx ++) {
list = lv_obj_get_style_list(obj, idx);
_lv_style_list_add_style(list, &styles->table_cell);
}
break;
}
#endif
#if LV_USE_WIN

View File

@@ -115,6 +115,8 @@ static void basic_init(void)
lv_style_set_bg_opa(&styles->scr, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->scr, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_text_color(&styles->scr, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_text_sel_color(&styles->scr, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_text_sel_bg_color(&styles->scr, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_value_color(&styles->scr, LV_STATE_DEFAULT, FG_COLOR);
style_init_reset(&styles->bg);
@@ -886,26 +888,21 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
case LV_THEME_TABLE: {
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
int idx = 1; /* start value should be 1, not zero, since cell styles
start at 1 due to presence of LV_TABLE_PART_BG=0
in the enum (lv_table.h) */
/* declaring idx outside loop to work with older compilers */
for(; idx <= LV_TABLE_CELL_STYLE_CNT; idx ++) {
list = lv_obj_get_style_list(obj, idx);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
}
break;
}
#endif
#if LV_USE_WIN

View File

@@ -42,7 +42,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static lv_theme_t theme;
static theme_styles_t * styles;
@@ -728,22 +727,20 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
case LV_THEME_TABLE: {
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
_lv_style_list_add_style(list, &styles->bg);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
_lv_style_list_add_style(list, &styles->bg);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
_lv_style_list_add_style(list, &styles->bg);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
int idx = 1; /* start value should be 1, not zero, since cell styles
start at 1 due to presence of LV_TABLE_PART_BG=0
in the enum (lv_table.h) */
/* declaring idx outside loop to work with older compilers */
for(; idx <= LV_TABLE_CELL_STYLE_CNT; idx ++) {
list = lv_obj_get_style_list(obj, idx);
_lv_style_list_add_style(list, &styles->bg);
}
break;
}
#endif
#if LV_USE_WIN

View File

@@ -737,6 +737,7 @@ static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_
anim_info->anim_start = anim_info->anim_end;
anim_info->anim_end = new_value;
}
*value_ptr = new_value;
/* Stop the previous animation if it exists */
lv_anim_del(anim_info, NULL);

View File

@@ -650,8 +650,10 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche
static lv_coord_t get_header_height(lv_obj_t * calendar)
{
const lv_font_t * font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_HEADER);
lv_style_int_t top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_HEADER);
lv_style_int_t top = lv_obj_get_style_margin_top(calendar, LV_CALENDAR_PART_HEADER) +
lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER);
lv_style_int_t bottom = lv_obj_get_style_margin_bottom(calendar, LV_CALENDAR_PART_HEADER) +
lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_HEADER);
return lv_font_get_line_height(font) + top + bottom;
}
@@ -677,7 +679,6 @@ static lv_coord_t get_day_names_height(lv_obj_t * calendar)
*/
static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
{
lv_style_int_t header_top = lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER);
lv_style_int_t header_left = lv_obj_get_style_pad_left(calendar, LV_CALENDAR_PART_HEADER);
lv_style_int_t header_right = lv_obj_get_style_pad_right(calendar, LV_CALENDAR_PART_HEADER);
const lv_font_t * font = lv_obj_get_style_text_font(calendar, LV_CALENDAR_PART_HEADER);
@@ -687,8 +688,9 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_area_t header_area;
header_area.x1 = calendar->coords.x1;
header_area.x2 = calendar->coords.x2;
header_area.y1 = calendar->coords.y1 + header_top;
header_area.y2 = header_area.y1 + lv_font_get_line_height(font);
header_area.y1 = calendar->coords.y1 + lv_obj_get_style_margin_top(calendar, LV_CALENDAR_PART_HEADER);
header_area.y2 = header_area.y1 + lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER) +
lv_font_get_line_height(font) + lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_HEADER);
lv_draw_rect_dsc_t header_rect_dsc;
lv_draw_rect_dsc_init(&header_rect_dsc);
@@ -711,6 +713,8 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_HEADER, &label_dsc);
label_dsc.flag = LV_TXT_FLAG_CENTER;
header_area.y1 += lv_obj_get_style_pad_top(calendar, LV_CALENDAR_PART_HEADER);
header_area.y2 -= lv_obj_get_style_pad_bottom(calendar, LV_CALENDAR_PART_HEADER);
lv_draw_label(&header_area, mask, &label_dsc, txt_buf, NULL);
calendar->state = state_ori; /*Restore the state*/

View File

@@ -51,10 +51,10 @@ static lv_style_list_t * lv_chart_get_style(lv_obj_t * chart, uint8_t part);
static void draw_series_bg(lv_obj_t * chart, const lv_area_t * series_area, const lv_area_t * mask);
static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, const lv_area_t * clip_area);
static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area, const lv_area_t * clip_area);
static void draw_cursors(lv_obj_t * chart, const lv_area_t * series_area, const lv_area_t * clip_area);
static void draw_axes(lv_obj_t * chart, const lv_area_t * series_area, const lv_area_t * mask);
static void invalidate_lines(lv_obj_t * chart, uint16_t i);
static void invalidate_columns(lv_obj_t * chart, uint16_t i);
static void get_series_area(lv_obj_t * chart, lv_area_t * series_area);
static void get_next_axis_label(lv_chart_label_iterator_t * iterator, char * buf);
static inline bool is_tick_with_label(uint8_t tick_num, lv_chart_axis_cfg_t * axis);
static lv_chart_label_iterator_t create_axis_label_iter(const char * list, uint8_t iterator_dir);
@@ -98,6 +98,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
}
_lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
_lv_ll_init(&ext->cursors_ll, sizeof(lv_chart_cursor_t));
uint8_t i;
for(i = 0; i < _LV_CHART_AXIS_LAST; i++) {
@@ -122,6 +123,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_init(&ext->style_series_bg);
lv_style_list_init(&ext->style_series);
lv_style_list_init(&ext->style_cursors);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(chart);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(chart);
@@ -140,6 +142,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_copy(&ext->style_series, &ext_copy->style_series);
lv_style_list_copy(&ext->style_series_bg, &ext_copy->style_series_bg);
lv_style_list_copy(&ext->style_cursors, &ext_copy->style_cursors);
ext->type = ext_copy->type;
ext->hdiv_cnt = ext_copy->hdiv_cnt;
@@ -204,6 +207,23 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
return ser;
}
lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * chart, lv_color_t color, lv_cursor_direction_t axes)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_chart_cursor_t * cursor = _lv_ll_ins_head(&ext->cursors_ll);
LV_ASSERT_MEM(cursor);
if(cursor == NULL) return NULL;
cursor->point.x = 0U;
cursor->point.y = LV_CHART_POINT_DEF;
cursor->color = color;
cursor->axes = axes;
return cursor;
}
/**
* Clear the point of a series
* @param chart pointer to a chart object
@@ -629,6 +649,23 @@ void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_char
lv_chart_refresh(chart);
}
/**
* Set the coordinate of the cursor with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object.
* @param cursor pointer to the cursor.
* @param point the new coordinate of cursor relative to the series area
*/
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * point)
{
LV_ASSERT_NULL(cursor);
LV_UNUSED(chart);
cursor->point.x = point->x;
cursor->point.y = point->y;
lv_chart_refresh(chart);
}
/*=====================
* Getter functions
*====================*/
@@ -702,6 +739,138 @@ lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * s
return ser->y_axis;
}
/**
* Get the coordinate of the cursor with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object
* @param cursor pointer to cursor
* @return coordinate of the cursor as lv_point_t
*/
lv_point_t lv_chart_get_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor)
{
LV_ASSERT_NULL(cursor);
LV_UNUSED(chart);
return cursor->point;
}
/**
* Get the nearest index to an X coordinate
* @param chart pointer to a chart object
* @param coord the coordination of the point relative to the series area.
* @return the found index
*/
uint16_t lv_chart_get_nearest_index_from_coord(lv_obj_t * chart, lv_coord_t x)
{
lv_area_t series_area;
lv_chart_get_series_area(chart, &series_area);
lv_coord_t w = lv_area_get_width(&series_area);
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(x < 0) return 0;
if(x > w) return ext->point_cnt - 1;
if(ext->type == LV_CHART_TYPE_LINE) return (x * (ext->point_cnt - 1) + w / 2) / w;
if(ext->type == LV_CHART_TYPE_COLUMN) return (x * ext->point_cnt) / w;
return 0;
}
/**
* Get the x coordinate of the an index with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object
* @param ser pointer to series
* @param id the index.
* @return x coordinate of index
*/
lv_coord_t lv_chart_get_x_from_index(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id)
{
LV_ASSERT_NULL(chart);
LV_ASSERT_NULL(ser);
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(id >= ext->point_cnt) {
LV_LOG_WARN("Invalid index: %d", id);
return 0;
}
lv_area_t series_area;
lv_chart_get_series_area(chart, &series_area);
lv_coord_t w = lv_area_get_width(&series_area);
lv_coord_t x = 0;
if(ext->type & LV_CHART_TYPE_LINE) {
x = (w * id) / (ext->point_cnt - 1);
}
else if(ext->type & LV_CHART_TYPE_COLUMN) {
lv_coord_t col_w = w / ((_lv_ll_get_len(&ext->series_ll) + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/
lv_chart_series_t * itr_ser = NULL;
lv_style_int_t col_space = lv_obj_get_style_pad_inner(chart, LV_CHART_PART_SERIES);
x = (int32_t)((int32_t)w * id) / ext->point_cnt;
x += col_w / 2; /*Start offset*/
_LV_LL_READ_BACK(ext->series_ll, itr_ser) {
if(itr_ser == ser) break;
x += col_w;
}
x += (col_w - col_space) / 2;
}
return x;
}
/**
* Get the y coordinate of the an index with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object
* @param ser pointer to series
* @param id the index.
* @return y coordinate of index
*/
lv_coord_t lv_chart_get_y_from_index(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id)
{
LV_ASSERT_NULL(chart);
LV_ASSERT_NULL(ser);
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(id >= ext->point_cnt) {
LV_LOG_WARN("Invalid index: %d", id);
return 0;
}
lv_area_t series_area;
lv_chart_get_series_area(chart, &series_area);
lv_coord_t h = lv_area_get_height(&series_area);
int32_t y = (int32_t)((int32_t)ser->points[id] - ext->ymin[ser->y_axis]) * h;
y = y / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
y = h - y;
return (lv_coord_t)y;
}
/**
* Get the series area of a chart.
* @param chart pointer to a chart object
* @param series_area pointer to an area variable that the result will be put in.
*/
void lv_chart_get_series_area(lv_obj_t * chart, lv_area_t * series_area)
{
lv_area_copy(series_area, &chart->coords);
series_area->x1 += lv_obj_get_style_pad_left(chart, LV_CHART_PART_BG);
series_area->x2 -= lv_obj_get_style_pad_right(chart, LV_CHART_PART_BG);
series_area->y1 += lv_obj_get_style_pad_top(chart, LV_CHART_PART_BG);
series_area->y2 -= lv_obj_get_style_pad_bottom(chart, LV_CHART_PART_BG);
}
/*=====================
* Other functions
*====================*/
@@ -744,7 +913,7 @@ static lv_design_res_t lv_chart_design(lv_obj_t * chart, const lv_area_t * clip_
lv_draw_rect(&chart->coords, clip_area, &bg_dsc);
lv_area_t series_area;
get_series_area(chart, &series_area);
lv_chart_get_series_area(chart, &series_area);
draw_series_bg(chart, &series_area, clip_area);
draw_axes(chart, &series_area, clip_area);
@@ -753,6 +922,7 @@ static lv_design_res_t lv_chart_design(lv_obj_t * chart, const lv_area_t * clip_
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext->type & LV_CHART_TYPE_LINE) draw_series_line(chart, &series_area, clip_area);
if(ext->type & LV_CHART_TYPE_COLUMN) draw_series_column(chart, &series_area, clip_area);
draw_cursors(chart, &series_area, clip_area);
}
return LV_DESIGN_RES_OK;
@@ -794,6 +964,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
_lv_ll_clear(&ext->series_ll);
lv_obj_clean_style_list(chart, LV_CHART_PART_SERIES);
lv_obj_clean_style_list(chart, LV_CHART_PART_CURSOR);
lv_obj_clean_style_list(chart, LV_CHART_PART_SERIES_BG);
}
@@ -824,6 +995,9 @@ static lv_style_list_t * lv_chart_get_style(lv_obj_t * chart, uint8_t part)
case LV_CHART_PART_SERIES:
style_dsc_p = &ext->style_series;
break;
case LV_CHART_PART_CURSOR:
style_dsc_p = &ext->style_cursors;
break;
default:
style_dsc_p = NULL;
}
@@ -1120,6 +1294,94 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area,
}
}
/**
* Draw the cursors as lines on a chart
* @param chart pointer to chart object
* @param clip_area the object will be drawn only in this area
*/
static void draw_cursors(lv_obj_t * chart, const lv_area_t * series_area, const lv_area_t * clip_area)
{
lv_area_t series_mask;
bool mask_ret = _lv_area_intersect(&series_mask, series_area, clip_area);
if(mask_ret == false) return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(_lv_ll_is_empty(&ext->cursors_ll)) return;
lv_point_t p1;
lv_point_t p2;
lv_chart_cursor_t * cursor;
lv_draw_line_dsc_t line_dsc;
lv_draw_line_dsc_init(&line_dsc);
lv_obj_init_draw_line_dsc(chart, LV_CHART_PART_CURSOR, &line_dsc);
lv_draw_rect_dsc_t point_dsc;
lv_draw_rect_dsc_init(&point_dsc);
point_dsc.bg_opa = line_dsc.opa;
point_dsc.radius = LV_RADIUS_CIRCLE;
lv_coord_t point_radius = lv_obj_get_style_size(chart, LV_CHART_PART_CURSOR);
/*Do not bother with line ending is the point will over it*/
if(point_radius > line_dsc.width / 2) line_dsc.raw_end = 1;
/*Go through all cursor lines*/
_LV_LL_READ_BACK(ext->cursors_ll, cursor) {
line_dsc.color = cursor->color;
point_dsc.bg_color = cursor->color;
if(cursor->axes & LV_CHART_CURSOR_RIGHT) {
p1.x = series_area->x1 + cursor->point.x;
p1.y = series_area->y1 + cursor->point.y;
p2.x = series_area->x2;
p2.y = p1.y;
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
}
if(cursor->axes & LV_CHART_CURSOR_UP) {
p1.x = series_area->x1 + cursor->point.x;
p1.y = series_area->y1;
p2.x = p1.x;
p2.y = series_area->y1 + cursor->point.y;
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
}
if(cursor->axes & LV_CHART_CURSOR_LEFT) {
p1.x = series_area->x1;
p1.y = series_area->y1 + cursor->point.y;
p2.x = p1.x + cursor->point.x;
p2.y = p1.y;
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
}
if(cursor->axes & LV_CHART_CURSOR_DOWN) {
p1.x = series_area->x1 + cursor->point.x;
p1.y = series_area->y1 + cursor->point.y;
p2.x = p1.x;
p2.y = series_area->y2;
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
}
if(point_radius) {
lv_area_t point_area;
point_area.x1 = series_area->x1 + cursor->point.x - point_radius;
point_area.x2 = series_area->x1 + cursor->point.x + point_radius;
point_area.y1 = series_area->y1 + cursor->point.y - point_radius;
point_area.y2 = series_area->y1 + cursor->point.y + point_radius;
/*Don't limit to `series_mask` to get full circles on the ends*/
lv_draw_rect(&point_area, clip_area, &point_dsc);
}
}
}
/**
* Create iterator for newline-separated list
* @param list pointer to newline-separated labels list
@@ -1358,7 +1620,10 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
/* set the area at some distance of the major tick len left of the tick */
lv_area_t a = {.y1 = p2.y - size.y / 2, .y2 = p2.y + size.y / 2};
/* changed to explicit member initialization to allow compilation as c++ */
lv_area_t a;
a.y1 = p2.y - size.y / 2;
a.y2 = p2.y + size.y / 2;
if(which_axis == LV_CHART_AXIS_PRIMARY_Y) {
a.x1 = p2.x - size.x - label_dist;
@@ -1497,7 +1762,7 @@ static void invalidate_lines(lv_obj_t * chart, uint16_t i)
if(i >= ext->point_cnt) return;
lv_area_t series_area;
get_series_area(chart, &series_area);
lv_chart_get_series_area(chart, &series_area);
lv_coord_t w = lv_area_get_width(&series_area);
lv_coord_t x_ofs = series_area.x1;
@@ -1534,7 +1799,7 @@ static void invalidate_columns(lv_obj_t * chart, uint16_t i)
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_area_t series_area;
get_series_area(chart, &series_area);
lv_chart_get_series_area(chart, &series_area);
lv_area_t col_a;
lv_coord_t w = lv_area_get_width(&series_area);
@@ -1552,13 +1817,4 @@ static void invalidate_columns(lv_obj_t * chart, uint16_t i)
_lv_inv_area(lv_obj_get_disp(chart), &col_a);
}
static void get_series_area(lv_obj_t * chart, lv_area_t * series_area)
{
lv_area_copy(series_area, &chart->coords);
series_area->x1 += lv_obj_get_style_pad_left(chart, LV_CHART_PART_BG);
series_area->x2 -= lv_obj_get_style_pad_right(chart, LV_CHART_PART_BG);
series_area->y1 += lv_obj_get_style_pad_top(chart, LV_CHART_PART_BG);
series_area->y2 -= lv_obj_get_style_pad_bottom(chart, LV_CHART_PART_BG);
}
#endif

View File

@@ -61,6 +61,15 @@ enum {
};
typedef uint8_t lv_chart_axis_t;
enum {
LV_CHART_CURSOR_NONE = 0x00,
LV_CHART_CURSOR_RIGHT = 0x01,
LV_CHART_CURSOR_UP = 0x02,
LV_CHART_CURSOR_LEFT = 0x04,
LV_CHART_CURSOR_DOWN = 0x08
};
typedef uint8_t lv_cursor_direction_t;
typedef struct {
lv_coord_t * points;
lv_color_t color;
@@ -69,6 +78,12 @@ typedef struct {
lv_chart_axis_t y_axis : 1;
} lv_chart_series_t;
typedef struct {
lv_point_t point;
lv_color_t color;
lv_cursor_direction_t axes : 4;
} lv_chart_cursor_t;
/** Data of axis */
enum {
LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */
@@ -90,6 +105,7 @@ typedef struct {
/*No inherited ext*/ /*Ext. of ancestor*/
/*New data for this type */
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/
lv_ll_t cursors_ll; /*Linked list for the cursor pointers (stores lv_chart_cursor_t)*/
lv_coord_t ymin[_LV_CHART_AXIS_LAST]; /*y min values for both axis (used to scale the data)*/
lv_coord_t ymax[_LV_CHART_AXIS_LAST]; /*y max values for both axis (used to scale the data)*/
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
@@ -97,6 +113,7 @@ typedef struct {
uint16_t point_cnt; /*Point number in a data line*/
lv_style_list_t style_series_bg;
lv_style_list_t style_series;
lv_style_list_t style_cursors;
lv_chart_type_t type; /*Line, column or point chart (from 'lv_chart_type_t')*/
lv_chart_axis_cfg_t y_axis;
lv_chart_axis_cfg_t x_axis;
@@ -108,7 +125,8 @@ typedef struct {
enum {
LV_CHART_PART_BG = LV_OBJ_PART_MAIN,
LV_CHART_PART_SERIES_BG = _LV_OBJ_PART_VIRTUAL_LAST,
LV_CHART_PART_SERIES
LV_CHART_PART_SERIES,
LV_CHART_PART_CURSOR
};
/**********************
@@ -136,6 +154,15 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy);
*/
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);
/**
* Add a cursor with a given color
* @param chart pointer to chart object
* @param color color of the cursor
* @param dir direction of the cursor. `LV_CHART_CURSOR_RIGHT/LEFT/TOP/DOWN`. OR-ed vaéues are possible
* @return pointer to the created cursor
*/
lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * chart, lv_color_t color, lv_cursor_direction_t dir);
/**
* Clear the point of a series
* @param chart pointer to a chart object
@@ -307,6 +334,16 @@ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t
*/
void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis);
/**
* Set the coordinate of the cursor with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object.
* @param cursor pointer to the cursor.
* @param point the new coordinate of cursor relative to the series area
*/
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * point);
/*=====================
* Getter functions
*====================*/
@@ -349,6 +386,50 @@ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint
*/
lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser);
/**
* Get an individual point y value in the chart series directly based on index
* @param chart pointer to a chart object
* @param series_area pointer to an area variable that the result will put in.
*/
void lv_chart_get_series_area(lv_obj_t * chart, lv_area_t * series_area);
/**
* Get the coordinate of the cursor with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object
* @param cursor pointer to cursor
* @return coordinate of the cursor as lv_point_t
*/
lv_point_t lv_chart_get_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor);
/**
* Get the nearest index to an X coordinate
* @param chart pointer to a chart object
* @param coord the coordination of the point relative to the series area.
* @return the found index
*/
uint16_t lv_chart_get_nearest_index_from_coord(lv_obj_t * chart, lv_coord_t x);
/**
* Get the x coordinate of the an index with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object
* @param ser pointer to series
* @param id the index.
* @return x coordinate of index
*/
lv_coord_t lv_chart_get_x_from_index(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id);
/**
* Get the y coordinate of the an index with respect
* to the origin of series area of the chart.
* @param chart pointer to a chart object
* @param ser pointer to series
* @param id the index.
* @return y coordinate of index
*/
lv_coord_t lv_chart_get_y_from_index(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id);
/*=====================
* Other functions
*====================*/

View File

@@ -132,6 +132,71 @@ void lv_checkbox_set_text_static(lv_obj_t * cb, const char * txt)
lv_label_set_text_static(ext->label, txt);
}
/**
* Set the state of the check box
* @param cb pointer to a check box object
* @param checked true: make the check box checked; false: make it unchecked
*/
void lv_checkbox_set_checked(lv_obj_t * cb, bool checked)
{
lv_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_btn_set_state(cb, checked ? LV_BTN_STATE_CHECKED_RELEASED : LV_BTN_STATE_RELEASED);
if(checked) {
lv_obj_add_state(ext->bullet, LV_STATE_CHECKED);
lv_obj_add_state(ext->label, LV_STATE_CHECKED);
}
else {
lv_obj_clear_state(ext->bullet, LV_STATE_CHECKED);
lv_obj_clear_state(ext->label, LV_STATE_CHECKED);
}
lv_obj_clear_state(ext->bullet, LV_STATE_DISABLED);
lv_obj_clear_state(ext->label, LV_STATE_DISABLED);
#if LV_USE_ANIMATION
lv_obj_finish_transitions(cb, LV_CHECKBOX_PART_BG);
lv_obj_finish_transitions(ext->bullet, LV_OBJ_PART_MAIN);
#endif
}
/**
* Make the check box inactive (disabled)
* @param cb pointer to a check box object
*/
void lv_checkbox_set_disabled(lv_obj_t * cb)
{
lv_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_btn_set_state(cb, LV_BTN_STATE_DISABLED);
lv_obj_add_state(ext->bullet, LV_STATE_DISABLED);
lv_obj_add_state(ext->label, LV_STATE_DISABLED);
#if LV_USE_ANIMATION
lv_obj_finish_transitions(cb, LV_CHECKBOX_PART_BG);
lv_obj_finish_transitions(ext->bullet, LV_OBJ_PART_MAIN);
#endif
}
/**
* Set the state of a check box
* @param cb pointer to a check box object
* @param state the new state of the check box (from lv_btn_state_t enum)
*/
void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state)
{
lv_checkbox_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_btn_set_state(cb, state);
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
#if LV_USE_ANIMATION
lv_obj_finish_transitions(cb, LV_CHECKBOX_PART_BG);
lv_obj_finish_transitions(ext->bullet, LV_OBJ_PART_MAIN);
#endif
}
/*=====================
* Getter functions
*====================*/

View File

@@ -92,29 +92,20 @@ void lv_checkbox_set_text_static(lv_obj_t * cb, const char * txt);
* @param cb pointer to a check box object
* @param checked true: make the check box checked; false: make it unchecked
*/
static inline void lv_checkbox_set_checked(lv_obj_t * cb, bool checked)
{
lv_btn_set_state(cb, checked ? LV_BTN_STATE_CHECKED_RELEASED : LV_BTN_STATE_RELEASED);
}
void lv_checkbox_set_checked(lv_obj_t * cb, bool checked);
/**
* Make the check box inactive (disabled)
* @param cb pointer to a check box object
*/
static inline void lv_checkbox_set_disabled(lv_obj_t * cb)
{
lv_btn_set_state(cb, LV_BTN_STATE_DISABLED);
}
void lv_checkbox_set_disabled(lv_obj_t * cb);
/**
* Set the state of a check box
* @param cb pointer to a check box object
* @param state the new state of the check box (from lv_btn_state_t enum)
*/
static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state)
{
lv_btn_set_state(cb, state);
}
void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state);
/*=====================
* Getter functions
*====================*/

View File

@@ -566,25 +566,35 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
lv_coord_t new_pinner = (w_obj - w_row) / (obj_num - 1);
lv_coord_t act_x = pleft; /*x init*/
child_tmp = child_rs;
lv_align_t align;
int32_t inv;
if(lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL) {
align = LV_ALIGN_IN_TOP_RIGHT;
inv = -1;
}
else {
align = LV_ALIGN_IN_TOP_LEFT;
inv = 1;
}
while(child_tmp != NULL) {
if(lv_obj_get_hidden(child_tmp) == false && lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
lv_coord_t mleft = lv_obj_get_style_margin_left(child_tmp, LV_OBJ_PART_MAIN);
lv_coord_t mright = lv_obj_get_style_margin_right(child_tmp, LV_OBJ_PART_MAIN);
switch(type) {
case LV_LAYOUT_PRETTY_TOP:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT,
act_x + mleft,
lv_obj_align(child_tmp, cont, align,
inv * (act_x + mleft),
act_y + lv_obj_get_style_margin_top(child_tmp, LV_OBJ_PART_MAIN));
break;
case LV_LAYOUT_PRETTY_MID:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT,
act_x + mleft,
lv_obj_align(child_tmp, cont, align,
inv * (act_x + mleft),
act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
break;
case LV_LAYOUT_PRETTY_BOTTOM:
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT,
act_x + mleft,
lv_obj_align(child_tmp, cont, align,
inv * (act_x + mleft),
act_y + h_row - lv_obj_get_height(child_tmp) - lv_obj_get_style_margin_bottom(child_tmp, LV_OBJ_PART_MAIN));
break;
default:

View File

@@ -53,7 +53,7 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id, lv_state_t state);
static lv_res_t page_release_handler(lv_obj_t * page);
static void page_press_handler(lv_obj_t * page);
static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y);
static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t y);
static void position_to_selected(lv_obj_t * ddlist);
static lv_obj_t * get_label(const lv_obj_t * ddlist);
@@ -588,6 +588,8 @@ void lv_dropdown_open(lv_obj_t * ddlist)
lv_obj_add_protect(ext->page, LV_PROTECT_POS | LV_PROTECT_CLICK_FOCUS);
lv_obj_add_protect(lv_page_get_scrollable(ext->page), LV_PROTECT_CLICK_FOCUS);
lv_obj_set_base_dir(ext->page, lv_obj_get_base_dir(ddlist));
if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(ext->page);
if(ancestor_page_scrl_signal == NULL) ancestor_page_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrollable(
ext->page));
@@ -675,6 +677,10 @@ void lv_dropdown_open(lv_obj_t * ddlist)
lv_obj_set_y(ext->page, lv_obj_get_y(ext->page) - (ext->page->coords.y2 - LV_VER_RES));
}
}
if(lv_label_get_align(label) == LV_LABEL_ALIGN_RIGHT) {
lv_obj_set_x(label, lv_obj_get_width_fit(ext->page) - lv_obj_get_width(label));
}
}
/**
@@ -737,7 +743,11 @@ static lv_design_res_t lv_dropdown_design(lv_obj_t * ddlist, const lv_area_t * c
const char * txt;
txt = ext->dir != LV_DROPDOWN_DIR_LEFT ? opt_txt : ext->symbol;
bool rev = false;
if(ext->dir == LV_DROPDOWN_DIR_LEFT) rev = true;
if(lv_obj_get_base_dir(ddlist) == LV_BIDI_DIR_RTL) rev = true;
txt = rev ? ext->symbol : opt_txt;
if(txt) {
_lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
label_dsc.flag);
@@ -757,7 +767,7 @@ static lv_design_res_t lv_dropdown_design(lv_obj_t * ddlist, const lv_area_t * c
lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL);
}
txt = ext->dir != LV_DROPDOWN_DIR_LEFT ? ext->symbol : opt_txt;
txt = rev ? opt_txt : ext->symbol;
if(txt) {
_lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
label_dsc.flag);
@@ -1236,7 +1246,7 @@ static lv_res_t page_release_handler(lv_obj_t * page)
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
lv_point_t p;
lv_indev_get_point(indev, &p);
ext->sel_opt_id = get_id_on_point(ddlist, p.x, p.y);
ext->sel_opt_id = get_id_on_point(ddlist, p.y);
ext->sel_opt_id_orig = ext->sel_opt_id;
}
@@ -1264,36 +1274,25 @@ static void page_press_handler(lv_obj_t * page)
if(indev && (lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON)) {
lv_point_t p;
lv_indev_get_point(indev, &p);
ext->pr_opt_id = get_id_on_point(ddlist, p.x, p.y);
ext->pr_opt_id = get_id_on_point(ddlist, p.y);
lv_obj_invalidate(page);
}
}
static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y)
static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t y)
{
lv_obj_t * label = get_label(ddlist);
if(label == NULL) return 0;
x -= label->coords.x1;
y -= label->coords.y1;
uint32_t letter_i;
const char * txt = lv_label_get_text(label);
const lv_font_t * font = lv_obj_get_style_text_font(label, LV_LABEL_PART_MAIN);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(label, LV_LABEL_PART_MAIN);
lv_point_t p = {x, y};
letter_i = lv_label_get_letter_on(label, &p);
uint32_t letter_i_byte_pos = _lv_txt_encoded_get_byte_id(txt, letter_i);
uint16_t opt = 0;
uint32_t i = 0;
uint32_t i_prev = 0;
y += line_space / 2;
lv_coord_t h = font_h + line_space;
uint32_t letter_cnt = 0;
for(letter_cnt = 0; letter_cnt < letter_i; letter_cnt++) {
uint32_t letter = _lv_txt_encoded_next(txt, &i);
/*Count the lines to reach the clicked letter. But ignore the last '\n' because it
* still belongs to the clicked line*/
if(letter == '\n' && i_prev != letter_i_byte_pos) opt++;
i_prev = i;
}
uint16_t opt = y / h;
return opt;
}

View File

@@ -706,10 +706,10 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
coords_tmp.y1 = zommed_coords.y1;
coords_tmp.y2 = zommed_coords.y1 + ext->h - 1;
for(; coords_tmp.y1 <= zommed_coords.y2; coords_tmp.y1 += zoomed_src_h, coords_tmp.y2 += zoomed_src_h) {
for(; coords_tmp.y1 < zommed_coords.y2; coords_tmp.y1 += zoomed_src_h, coords_tmp.y2 += zoomed_src_h) {
coords_tmp.x1 = zommed_coords.x1;
coords_tmp.x2 = zommed_coords.x1 + ext->w - 1;
for(; coords_tmp.x1 <= zommed_coords.x2; coords_tmp.x1 += zoomed_src_w, coords_tmp.x2 += zoomed_src_w) {
for(; coords_tmp.x1 < zommed_coords.x2; coords_tmp.x1 += zoomed_src_w, coords_tmp.x2 += zoomed_src_w) {
lv_draw_img(&coords_tmp, &clip_real, ext->src, &img_dsc);
}
}

View File

@@ -170,6 +170,26 @@ void lv_imgbtn_set_src_tiled(lv_obj_t * imgbtn, lv_btn_state_t state, const void
#endif
/**
* Set the state of the image button
* @param imgbtn pointer to an image button object
* @param state the new state of the button (from lv_btn_state_t enum)
*/
void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_btn_state_t state)
{
lv_btn_set_state(imgbtn, state);
refr_img(imgbtn);
}
/**
* Toggle the state of the image button (ON->OFF, OFF->ON)
* @param imgbtn pointer to a image button object
*/
void lv_imgbtn_toggle(lv_obj_t * imgbtn)
{
lv_imgbtn_toggle(imgbtn);
refr_img(imgbtn);
}
/*=====================
* Getter functions
*====================*/
@@ -468,6 +488,9 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, top);
imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, bottom);
}
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
refr_img(imgbtn);
}
else if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
}

View File

@@ -98,6 +98,19 @@ void lv_imgbtn_set_src_tiled(lv_obj_t * imgbtn, lv_btn_state_t state, const void
#endif
/**
* Set the state of the image button
* @param imgbtn pointer to an image button object
* @param state the new state of the button (from lv_btn_state_t enum)
*/
void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_btn_state_t state);
/**
* Toggle the state of the image button (ON->OFF, OFF->ON)
* @param imgbtn pointer to a image button object
*/
void lv_imgbtn_toggle(lv_obj_t * imgbtn);
/**
* Enable the toggled states. On release the button will change from/to toggled state.
* @param imgbtn pointer to an image button object
@@ -108,24 +121,6 @@ static inline void lv_imgbtn_set_checkable(lv_obj_t * imgbtn, bool tgl)
lv_btn_set_checkable(imgbtn, tgl);
}
/**
* Set the state of the image button
* @param imgbtn pointer to an image button object
* @param state the new state of the button (from lv_btn_state_t enum)
*/
static inline void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_btn_state_t state)
{
lv_btn_set_state(imgbtn, state);
}
/**
* Toggle the state of the image button (ON->OFF, OFF->ON)
* @param imgbtn pointer to a image button object
*/
static inline void lv_imgbtn_toggle(lv_obj_t * imgbtn)
{
lv_btn_toggle(imgbtn);
}
/*=====================
* Getter functions

View File

@@ -189,7 +189,9 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy)
void lv_keyboard_set_textarea(lv_obj_t * kb, lv_obj_t * ta)
{
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
if(ta) LV_ASSERT_OBJ(ta, "lv_textarea");
if(ta) {
LV_ASSERT_OBJ(ta, "lv_textarea");
}
lv_keyboard_ext_t * ext = lv_obj_get_ext_attr(kb);

View File

@@ -276,7 +276,9 @@ bool lv_list_remove(const lv_obj_t * list, uint16_t index)
void lv_list_focus_btn(lv_obj_t * list, lv_obj_t * btn)
{
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
if(btn) LV_ASSERT_OBJ(btn, "lv_btn");
if(btn) {
LV_ASSERT_OBJ(btn, "lv_btn");
}
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);

View File

@@ -132,7 +132,6 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_signal_cb(page, lv_page_signal);
lv_obj_set_design_cb(page, lv_page_design);
lv_page_set_scrollbar_mode(page, ext->scrlbar.mode);
lv_theme_apply(page, LV_THEME_PAGE);

View File

@@ -1,4 +1,3 @@
/**
* @file lv_roller.c
*

View File

@@ -126,8 +126,8 @@ void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim)
#if LV_USE_ANIMATION == 0
anim = LV_ANIM_OFF;
#endif
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
ext->state = 1;
if(lv_bar_get_value(sw) == 1)
return;
lv_bar_set_value(sw, 1, anim);
lv_obj_add_state(sw, LV_STATE_CHECKED);
}
@@ -144,8 +144,8 @@ void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim)
#if LV_USE_ANIMATION == 0
anim = LV_ANIM_OFF;
#endif
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
ext->state = 0;
if(lv_bar_get_value(sw) == 0)
return;
lv_bar_set_value(sw, 0, anim);
lv_obj_clear_state(sw, LV_STATE_CHECKED);
}

View File

@@ -37,7 +37,6 @@ typedef struct {
lv_bar_ext_t bar; /*Ext. of ancestor*/
/*New data for this type */
lv_style_list_t style_knob; /*Style of the knob*/
uint8_t state : 1; /*The current state*/
} lv_switch_ext_t;
/**
@@ -112,8 +111,7 @@ static inline void lv_switch_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
*/
static inline bool lv_switch_get_state(const lv_obj_t * sw)
{
lv_switch_ext_t * ext = (lv_switch_ext_t *)lv_obj_get_ext_attr(sw);
return ext->state ? true : false;
return lv_bar_get_value(sw) == 1 ? true : false;
}
/**

View File

@@ -14,6 +14,7 @@
#include "../lv_misc/lv_txt.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_label.h"
#include "../lv_misc/lv_printf.h"
#include "../lv_themes/lv_theme.h"
/*********************
@@ -169,11 +170,117 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const
format.s.crop = 0;
}
#if LV_USE_ARABIC_PERSIAN_CHARS
/*Get the size of the Arabic text and process it*/
size_t len_ap = _lv_txt_ap_calc_bytes_cnt(txt);
ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], len_ap + 1);
LV_ASSERT_MEM(ext->cell_data[cell]);
if(ext->cell_data[cell] == NULL) return;
_lv_txt_ap_proc(txt, &ext->cell_data[cell][1]);
#else
ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/
LV_ASSERT_MEM(ext->cell_data[cell]);
if(ext->cell_data[cell] == NULL) return;
strcpy(ext->cell_data[cell] + 1, txt); /*+1 to skip the format byte*/
#endif
ext->cell_data[cell][0] = format.format_byte;
refr_size(table);
}
/**
* Set the value of a cell. Memory will be allocated to store the text by the table.
* @param table pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param fmt `printf`-like format
*/
void lv_table_set_cell_value_fmt(lv_obj_t * table, uint16_t row, uint16_t col, const char * fmt, ...)
{
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
LV_ASSERT_STR(fmt);
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
if(col >= ext->col_cnt) {
LV_LOG_WARN("lv_table_set_cell_value: invalid column");
return;
}
/*Auto expand*/
if(row >= ext->row_cnt) {
lv_table_set_row_cnt(table, row + 1);
}
uint32_t cell = row * ext->col_cnt + col;
lv_table_cell_format_t format;
/*Save the format byte*/
if(ext->cell_data[cell]) {
format.format_byte = ext->cell_data[cell][0];
}
/*Initialize the format byte*/
else {
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table);
if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_LABEL_ALIGN_LEFT;
else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_LABEL_ALIGN_RIGHT;
else if(base_dir == LV_BIDI_DIR_AUTO)
#if LV_USE_BIDI
format.s.align = _lv_bidi_detect_base_dir(fmt);
#else
format.s.align = LV_LABEL_ALIGN_LEFT;
#endif
format.s.right_merge = 0;
format.s.type = 0;
format.s.crop = 0;
}
va_list ap, ap2;
va_start(ap, fmt);
va_copy(ap2, ap);
/*Allocate space for the new text by using trick from C99 standard section 7.19.6.12 */
uint32_t len = lv_vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
#if LV_USE_ARABIC_PERSIAN_CHARS
/*Put together the text according to the format string*/
char * raw_txt = _lv_mem_buf_get(len + 1);
LV_ASSERT_MEM(raw_txt);
if(raw_txt == NULL) {
va_end(ap2);
return;
}
lv_vsnprintf(raw_txt, len + 1, fmt, ap2);
/*Get the size of the Arabic text and process it*/
size_t len_ap = _lv_txt_ap_calc_bytes_cnt(raw_txt);
ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], len_ap + 1);
LV_ASSERT_MEM(ext->cell_data[cell]);
if(ext->cell_data[cell] == NULL) {
va_end(ap2);
return;
}
_lv_txt_ap_proc(raw_txt, &ext->cell_data[cell][1]);
_lv_mem_buf_release(raw_txt);
#else
ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], len + 2); /*+1: trailing '\0; +1: format byte*/
LV_ASSERT_MEM(ext->cell_data[cell]);
if(ext->cell_data[cell] == NULL) {
va_end(ap2);
return;
}
ext->cell_data[cell][len + 1] = 0; /* Ensure NULL termination */
lv_vsnprintf(&ext->cell_data[cell][1], len + 1, fmt, ap2);
#endif
va_end(ap2);
ext->cell_data[cell][0] = format.format_byte;
refr_size(table);
@@ -741,6 +848,8 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
uint16_t row;
uint16_t cell = 0;
bool rtl = lv_obj_get_base_dir(table) == LV_BIDI_DIR_RTL ? true : false;
cell_area.y2 = table->coords.y1 + bg_top - 1;
for(row = 0; row < ext->row_cnt; row++) {
lv_coord_t h_row = ext->row_h[row];
@@ -750,7 +859,8 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
if(cell_area.y1 > clip_area->y2) return LV_DESIGN_RES_OK;
cell_area.x2 = table->coords.x1 + bg_left - 1;
if(rtl) cell_area.x1 = table->coords.x2 - bg_right - 1;
else cell_area.x2 = table->coords.x1 + bg_left - 1;
for(col = 0; col < ext->col_cnt; col++) {
@@ -765,15 +875,22 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
format.s.crop = 1;
}
if(rtl) {
cell_area.x2 = cell_area.x1 - 1;
cell_area.x1 = cell_area.x2 - ext->col_w[col] + 1;
}
else {
cell_area.x1 = cell_area.x2 + 1;
cell_area.x2 = cell_area.x1 + ext->col_w[col] - 1;
}
uint16_t col_merge = 0;
for(col_merge = 0; col_merge + col < ext->col_cnt - 1; col_merge++) {
if(ext->cell_data[cell + col_merge] != NULL) {
format.format_byte = ext->cell_data[cell + col_merge][0];
if(format.s.right_merge)
cell_area.x2 += ext->col_w[col + col_merge + 1];
if(rtl) cell_area.x1 -= ext->col_w[col + col_merge + 1];
else cell_area.x2 += ext->col_w[col + col_merge + 1];
else
break;
}
@@ -947,34 +1064,21 @@ static lv_style_list_t * lv_table_get_style(lv_obj_t * table, uint8_t part)
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
lv_style_list_t * style_dsc_p;
switch(part) {
case LV_TABLE_PART_BG:
style_dsc_p = &table->style_list;
break;
case LV_TABLE_PART_CELL1:
style_dsc_p = &ext->cell_style[0];
break;
case LV_TABLE_PART_CELL2:
style_dsc_p = &ext->cell_style[1];
break;
case LV_TABLE_PART_CELL3:
style_dsc_p = &ext->cell_style[2];
break;
case LV_TABLE_PART_CELL4:
style_dsc_p = &ext->cell_style[3];
break;
default:
style_dsc_p = NULL;
/* Because of the presence of LV_TABLE_PART_BG, LV_TABLE_PART_CELL<i> has an integer value
of <i>. This comes in useful to extend above code with more cell types as follows */
if(part == LV_TABLE_PART_BG) {
return &table->style_list;
}
else if(part >= 1 && part <= LV_TABLE_CELL_STYLE_CNT) {
return &ext->cell_style[part - 1];
}
return style_dsc_p;
return NULL;
}
static void refr_size(lv_obj_t * table)
{
lv_coord_t h = 0;
lv_coord_t w = 0;

View File

@@ -32,7 +32,17 @@ extern "C" {
#define LV_TABLE_COL_MAX 12
#endif
#define LV_TABLE_CELL_STYLE_CNT 4
/*
Maximum allowable value of LV_TABLE_CELL_STYLE_CNT is 16
because of restriction of lv_table_cell_format_t.type to no more than
4 bits so that lv_table_cell_format_t.s will not exceed 8 bits
*/
#ifndef LV_TABLE_CELL_STYLE_CNT
# define LV_TABLE_CELL_STYLE_CNT 4
#endif
#if (LV_TABLE_CELL_STYLE_CNT > 16)
# error LV_TABLE_CELL_STYLE_CNT cannot exceed 16
#endif
/**********************
* TYPEDEFS
**********************/
@@ -46,7 +56,7 @@ typedef union {
struct {
uint8_t align : 2;
uint8_t right_merge : 1;
uint8_t type : 2;
uint8_t type : 4; // upto 16 values
uint8_t crop : 1;
} s;
uint8_t format_byte;
@@ -61,16 +71,18 @@ typedef struct {
lv_coord_t * row_h;
lv_style_list_t cell_style[LV_TABLE_CELL_STYLE_CNT];
lv_coord_t col_w[LV_TABLE_COL_MAX];
uint8_t cell_types : 4; /*Keep track which cell types exists to avoid dealing with unused ones*/
uint16_t cell_types :
LV_TABLE_CELL_STYLE_CNT; /*Keep track which cell types exists to avoid dealing with unused ones*/
} lv_table_ext_t;
/*Parts of the table*/
enum {
LV_TABLE_PART_BG,
LV_TABLE_PART_CELL1,
LV_TABLE_PART_CELL2,
LV_TABLE_PART_BG, /* Because of this member, LV_PART.*CELL1 has enum value of 1, */
LV_TABLE_PART_CELL1, /* LV_PART.*CELL2 has an enum value of 2 and so on upto the maximum */
LV_TABLE_PART_CELL2, /* number of styles specified by LV_TABLE_CELL_STYLE_CNT */
LV_TABLE_PART_CELL3,
LV_TABLE_PART_CELL4,
LV_TABLE_PART_CELL4, /* CELL 5-16 are not needed to be defined, the values in this enum
are there for backward compatibility */
};
/**********************
@@ -99,6 +111,15 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy);
*/
void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const char * txt);
/**
* Set the value of a cell. Memory will be allocated to store the text by the table.
* @param table pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param fmt `printf`-like format
*/
void lv_table_set_cell_value_fmt(lv_obj_t * table, uint16_t row, uint16_t col, const char * fmt, ...);
/**
* Set the number of rows
* @param table table pointer to a Table object

View File

@@ -260,7 +260,6 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
return;
}
/*If a new line was added it shouldn't show edge flash effect*/
bool edge_flash_en = lv_textarea_get_edge_flash(ta);
lv_textarea_set_edge_flash(ta, false);

View File

@@ -172,8 +172,9 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
void lv_win_clean(lv_obj_t * win)
{
LV_ASSERT_OBJ(win, LV_OBJX_NAME);
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_obj_t * scrl = lv_page_get_scrollable(win);
lv_obj_t * scrl = lv_page_get_scrollable(ext->page);
lv_obj_clean(scrl);
}

View File

@@ -7,12 +7,12 @@
* INCLUDES
*********************/
#include "lvgl/lvgl.h"
#include "../../lvgl.h"
#if LV_BUILD_TEST
#include "../lv_test_assert.h"
#include "lvgl/src/lv_font/lv_font_fmt_txt.h"
#include "lvgl/src/lv_font/lv_font.h"
#include "lvgl/src/lv_font/lv_font_loader.h"
#include "../src/lv_font/lv_font_fmt_txt.h"
#include "../src/lv_font/lv_font.h"
#include "../src/lv_font/lv_font_loader.h"
#include "lv_test_font_loader.h"

View File

@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"
/*******************************************************************************
* Size: 8 px

View File

@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"
/*******************************************************************************
* Size: 8 px

View File

@@ -1,4 +1,4 @@
#include "lvgl/lvgl.h"
#include "../../lvgl.h"
/*******************************************************************************
* Size: 20 px