1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

merge dev

This commit is contained in:
Gabor Kiss-Vamosi 2020-10-22 14:32:58 +02:00
commit 872bbc7e3e
55 changed files with 6993 additions and 787 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:

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
scripts/release/__pycache__
**/*.o
**/*bin
**/*.swp

View File

@ -1,14 +1,44 @@
# Changelog
## v7.7.0 (06.10.2020)
## v7.8.0 (20.10.2020)
### New features
- make DMA2D non blocking
## v7.7.1 (04.11.2020)
### Bugfixes
## 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)
@ -18,8 +48,6 @@
### Bugfixes
- Fix selection of options with non-ASCII letters in dropdown list
- Fix font loader to support LV_FONT_FMT_TXT_LARGE
- Fix BIDI support in dropdown list
- Fix copying base dir in lv_obj_craete
## v7.5.0 (15.09.2020)

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,10 +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`
- Make the `copy` parameter of `create` functions deprecated
## v8.1
- Add radio button widget
@ -32,10 +38,18 @@ Planned to September/October 2020
- 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)
- 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.1",
"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.1
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.7.0-dev
* Configuration file for v7.7.1-dev
*/
/*
@ -205,6 +205,8 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
* */
#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
@ -260,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

2
lvgl.h
View File

@ -17,7 +17,7 @@ extern "C" {
#define LVGL_VERSION_MAJOR 8
#define LVGL_VERSION_MINOR 0
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO "dev"
#define LVGL_VERSION_INFO ""
/*********************
* INCLUDES

View File

@ -27,6 +27,9 @@ fout.write(
#define LV_CONF_INTERNAL_H
/* clang-format off */
/*Handle special Kconfig options*/
#include "lv_conf_kconfig.h"
#include <stdint.h>
/*If lv_conf.h is not skipped include it*/

View File

@ -1,518 +0,0 @@
#!/usr/bin/env python
# Release lvgl, lv_examples, lv_drivers. docs, blog and prepare the development of the next major, minoror bugfix release
# Usage: ./release,py bugfix | minor | major
# The option means what type of versin to prepare for development after release
#
# STEPS:
# - clone all 5 repos
# - get the version numnber from lvgl.h
# - set release branch (e.g. "release/v7")
# - prepare lvgl
# - run lv_conf_internal.py
# - run code formatter
# - clear LVGL_VERSION_INFO (set to "")
# - run Doxygen
# - update the version in lvgl's library.json, library.properties, lv_conf_template.h
# - update CHANGELOG.md
# - commit changes
# - prepare lv_examples
# - upadte the required LVGL version in lv_examples.h (LV_VERSION_CHECK)
# - update the version in lv_ex_conf_template.h
# - prepare lv_drivers
# - update the version in library.json, lv_drv_conf_template.h
# - prepare docs
# - update API XML
# - clear the versiopn info (should be plain vx.y.z)
# - tag all repos with the new version
# - merge to release branches
# - blog: add release post
# - push tags and commits
# - docs: run ./updade.py release/vX
#
# If --patch
# - merge master to dev branches
# - increment patch version by 1 and append "-dev". E.g. "vX.Y.(Z+1)-dev"
# - update version numbers in lvgl and docs
# - commit and push
# - docs: run ./updade.py latest dev
#
# Else (not --patch)
# - merge master to dev
# - merge the dev to master
# - increment version number like "vX.(Y+1).0-dev"
# - apply the new version in dev branches of lvgl, lv_examples, lv_drivers, docs
# - commit and push to dev branches
# - docs: run ./updade.py latest dev
import re
import os, fnmatch
import os.path
from os import path
from datetime import date
import sys
upstream_org_url = "https://github.com/lvgl/"
workdir = "./release_tmp"
proj_list = [ "lv_sim_eclipse_sdl"]
ver_major = -1
ver_minor = -1
ver_patch = -1
dev_ver_major = -1
dev_ver_minor = -1
dev_ver_patch = -1
ver_str = ""
dev_ver_str = ""
release_br = ""
release_note = ""
prepare_type = ['major', 'minor', 'bugfix']
dev_prepare = 'minor'
def upstream(repo):
return upstream_org_url + repo + ".git"
def cmd(c, exit_on_err = True):
print("\n" + c)
r = os.system(c)
if r:
print("### Error: " + str(r))
if exit_on_err: exit(int(r))
def define_set(fn, name, value):
print("In " + fn + " set " + name + " to " + value)
new_content = ""
s = r'^ *# *define +' + str(name).rstrip()
f = open(fn, "r")
for i in f.read().splitlines():
r = re.search(s, i)
if r:
d = i.split("define")
i = d[0] + "define " + name + " " + value
new_content += i + '\n'
f.close()
f = open(fn, "w")
f.write(new_content)
f.close()
def clone_repos():
cmd("rm -fr " + workdir)
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; ")
cmd("git clone --recurse-submodules " + upstream("docs") + "; cd docs; git checkout master; git remote update origin --prune; ")
cmd("git clone " + upstream("blog") + "; cd blog; git checkout master; git remote update origin --prune; ")
for p in proj_list:
cmd("git clone " + upstream(p) + " --recurse-submodules ; cd " + p + "; git checkout master; git remote update origin --prune; ")
def get_lvgl_version(br):
print("Get LVGL's version")
global ver_str, ver_major, ver_minor, ver_patch, release_br
os.chdir("./lvgl")
cmd("git checkout " + br)
f = open("./lvgl.h", "r")
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
for i in f.read().splitlines():
r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
if r:
m = lastNum.search(i)
if m: ver_major = m.group(1)
r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
if r:
m = lastNum.search(i)
if m: ver_minor = m.group(1)
r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
if r:
m = lastNum.search(i)
if m: ver_patch = m.group(1)
f.close()
cmd("git checkout master")
ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch)
print("New version:" + ver_str)
release_br = "release/v" + ver_major
os.chdir("../")
def update_version():
templ = fnmatch.filter(os.listdir('.'), '*templ*')
if templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' " + templ[0])
if os.path.exists("library.json"):
print("Updating version in library.json")
cmd("sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str[1:] +"/' library.json")
if path.exists("library.properties"):
print("Updating version in library.properties")
cmd("sed -i -r 's/version=[0-9]+\.[0-9]+\.[0-9]+/"+ "version=" + ver_str[1:] + "/' library.properties")
def lvgl_prepare():
print("Prepare lvgl")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./lvgl")
define_set("./lvgl.h", "LVGL_VERSION_INFO", '\"\"')
# Run some scripts
os.chdir("./scripts")
cmd("./code-format.sh")
cmd("./lv_conf_checker.py")
cmd("doxygen")
os.chdir("../")
update_version()
#update CHANGLELOG
new_content = ""
f = open("./CHANGELOG.md", "r")
global release_note
release_note = ""
note_state = 0
for i in f.read().splitlines():
if note_state == 0:
r = re.search(r'^## ' + ver_str, i)
if r:
i = i.replace("planned on ", "")
note_state+=1
elif note_state == 1:
r = re.search(r'^## ', i)
if r:
note_state+=1
else:
release_note += i + '\n'
new_content += i + '\n'
f.close()
f = open("./CHANGELOG.md", "w")
f.write(new_content)
f.close()
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def lv_examples_prepare():
print("Prepare lv_examples")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./lv_examples")
update_version()
cmd("sed -i -r 's/LV_VERSION_CHECK\([0-9]+, *[0-9]+, *[0-9]+\)/"+ "LV_VERSION_CHECK(" + ver_major + ", " + ver_minor + ", " + ver_patch + ")/' lv_examples.h")
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def lv_drivers_prepare():
print("Prepare lv_drivers")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./lv_drivers")
update_version()
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def docs_prepare():
print("Prepare docs")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./docs")
cmd("git co latest --")
cmd("rm -rf xml");
cmd("cp -r ../lvgl/docs/api_doc/xml .");
cmd("git add xml");
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py")
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def blog_add_post():
global ver_str, release_note
os.chdir("./blog/_posts")
post = "---\nlayout: post\ntitle: " + ver_str + " is released\nauthor: \"kisvegabor\"\ncover: /assets/release_cover.png\n---\n\n"
post += release_note
today = date.today()
d = today.strftime("%Y-%m-%d")
f = open(d + "-release_" + ver_str + ".md", "w")
f.write(post)
f.close()
cmd("git add .")
cmd("git commit -am 'Add " + ver_str + " release post'")
os.chdir("../../")
def add_tags():
global ver_str
tag_cmd = " git tag -a " + ver_str + " -m 'Release " + ver_str + "' "
cmd("cd lvgl; " + tag_cmd)
cmd("cd lv_examples; " + tag_cmd)
cmd("cd lv_drivers; " + tag_cmd)
cmd("cd docs; " + tag_cmd)
def update_release_branches():
global release_br
merge_cmd = " git checkout " + release_br + "; git pull origin " + release_br + "; git merge master -X ours; git push origin " + release_br + "; git checkout master"
cmd("cd lvgl; " + merge_cmd)
cmd("cd lv_examples; " + merge_cmd)
cmd("cd lv_drivers; " + merge_cmd)
merge_cmd = " git checkout " + release_br + "; git pull origin " + release_br + "; git merge latest -X ours; git push origin " + release_br + "; git checkout latest"
cmd("cd docs; " + merge_cmd)
def publish_master():
#Merge LVGL master to dev first to avoid "merge-to-dev.yml" running asynchronous
os.chdir("./lvgl")
cmd("git checkout dev")
cmd("git merge master -X ours")
cmd("git add .")
cmd("git commit -am 'Merge master'", False)
cmd("git push origin dev")
cmd("git checkout master")
os.chdir("../")
pub_cmd = "git push origin master; git push origin " + ver_str
cmd("cd lvgl; " + pub_cmd)
cmd("cd lv_examples; " + pub_cmd)
cmd("cd lv_drivers; " + pub_cmd)
pub_cmd = "git push origin master"
cmd("cd blog; " + pub_cmd)
def merge_from_dev():
merge_cmd = "git checkout master; git merge dev;"
cmd("cd lvgl; " + merge_cmd)
merge_cmd = "git checkout latest -- ; git merge dev -X theirs --no-edit;"
cmd("cd docs; " + merge_cmd)
def lvgl_update_master_version():
global ver_major, ver_minor, ver_patch, ver_str
os.chdir("./lvgl")
cmd("git checkout master")
define_set("./lvgl.h", "LVGL_VERSION_MAJOR", ver_major)
define_set("./lvgl.h", "LVGL_VERSION_MINOR", ver_minor)
define_set("./lvgl.h", "LVGL_VERSION_PATCH", ver_patch)
define_set("./lvgl.h", "LVGL_VERSION_INFO", "dev")
templ = fnmatch.filter(os.listdir('.'), '*templ*')
if templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ ver_str +"/' " + templ[0])
cmd("git commit -am 'Update version'")
os.chdir("../")
def docs_update_latest_version():
global ver_str
os.chdir("./docs")
cmd("git checkout latest --")
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py")
cmd("git commit -am 'Update version'")
cmd("git checkout master --")
os.chdir("../")
def lvgl_update_dev_version():
global ver_major, ver_minor, ver_patch, dev_ver_str
os.chdir("./lvgl")
cmd("git checkout dev")
define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver_major))
define_set("./lvgl.h", "LVGL_VERSION_MINOR", str(ver_minor))
define_set("./lvgl.h", "LVGL_VERSION_PATCH", str(ver_patch))
define_set("./lvgl.h", "LVGL_VERSION_INFO", "\"dev\"")
templ = fnmatch.filter(os.listdir('.'), '*templ*')
if templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ dev_ver_str +"/' " + templ[0])
cmd("git commit -am 'Update dev version'")
cmd("git checkout master")
os.chdir("../")
def docs_update_dev_version():
global dev_ver_str
os.chdir("./docs")
cmd("git checkout dev --")
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + dev_ver_str + "'/\" conf.py")
cmd("git commit -am 'Update dev version'")
cmd("git checkout master --")
os.chdir("../")
def publish_dev_and_master():
pub_cmd = "git checkout dev; git push origin dev"
cmd("cd lvgl; " + pub_cmd)
pub_cmd = "git checkout master; git push origin master"
cmd("cd lvgl; " + pub_cmd)
def projs_update():
global proj_list, release_br, ver_str
for p in proj_list:
os.chdir("./" + p)
cmd('git checkout master')
print(p + ": upadte lvgl");
cmd("cd lvgl; git co " + release_br + "; git pull origin " + release_br)
cmd("cp -f lvgl/lv_conf_template.h lv_conf.h")
cmd("sed -i -r 's/#if 0/#if 1/' lv_conf.h") # Enable lv_conf.h
d = {}
with open("confdef.txt") as f:
for line in f:
(key, val) = line.rstrip().split('\t')
d[key] = val
for k,v in d.items():
define_set("lv_conf.h", str(k), str(v))
if os.path.exists("lv_examples"):
print(p + ": upadte lv_examples");
cmd("cd lv_examples; git co " + release_br + "; git pull origin " + release_br)
if os.path.exists("lv_drivers"):
print(p + ": upadte lv_drivers");
cmd("cd lv_drivers " + release_br + "; git pull origin " + release_br)
msg = 'Update to ' + ver_str
cmd("git add .")
cmd('git commit -am "' + msg + '"')
cmd('git push origin master')
cmd("git tag -a " + ver_str + " -m '" + msg + "' " )
cmd('git push origin ' + ver_str)
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'
if(len(sys.argv) != 2):
print("Missing argument. Usage ./release.py bugfix | minor | major")
print("Use minor by deafult")
else:
dev_prepare = sys.argv[1]
if not (dev_prepare in prepare_type):
print("Invalid argument. Usage ./release.py bugfix | minor | major")
exit(1)
clone_repos()
get_lvgl_version("dev")
dev_ver_major = ver_major
dev_ver_minor = ver_minor
dev_ver_patch = ver_patch
dev_ver_str = ver_str
get_lvgl_version("master")
lvgl_prepare()
lv_examples_prepare()
lv_drivers_prepare()
docs_prepare()
blog_add_post()
add_tags()
update_release_branches()
publish_master()
projs_update()
if dev_prepare == 'bugfix':
ver_patch = str(int(ver_patch) + 1)
ver_str = "v" + ver_major + "." + ver_minor + "." + ver_patch + "-dev"
print("Prepare bugfix version " + ver_str)
lvgl_update_master_version()
docs_update_latest_version()
else:
#merge_from_dev()
get_lvgl_version("master")
if dev_prepare == 'minor':
ver_minor = str(int(ver_minor) + 1)
ver_patch = "0"
else:
ver_major = str(int(ver_major) + 1)
ver_minor = "0"
ver_patch = "0"
dev_ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch) + "-dev"
print("Prepare minor version " + dev_ver_str)
lvgl_update_dev_version()
docs_update_dev_version()
publish_dev_and_master()
docs_update_all();
cleanup()

109
scripts/release/com.py Executable file
View File

@ -0,0 +1,109 @@
#!/usr/bin/env python
import sys
import os.path
from os import path
import os, fnmatch
import re
import subprocess
import com
def cmd(c, ask_on_err = True):
print("\n" + c)
r = os.system(c)
if r:
print("### Error: " + str(r))
if exit_on_err:
input("Press Enter to continue exectution...")
def define_set(fn, name, value):
print("In " + fn + " set " + name + " to " + value)
new_content = ""
s = r'^ *# *define +' + str(name).rstrip() + ' +'
f = open(fn, "r")
for i in f.read().splitlines():
r = re.search(s, i)
if r:
d = i.split("define")
i = d[0] + "define " + name + " " + value
new_content += i + '\n'
f.close()
f = open(fn, "w")
f.write(new_content)
f.close()
def ver_format(ver):
s = "v" + str(ver[0]) + "." + str(ver[1]) + "." + str(ver[2])
if(ver[3] != ""): s = s + "-" + ver[3]
return s
def get_lvgl_version(br):
print("Get LVGL's version")
ver = [0, 0, 0, ""]
os.chdir("./lvgl")
com.cmd("git checkout " + br)
f = open("./lvgl.h", "r")
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
for i in f.read().splitlines():
r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
if r:
m = lastNum.search(i)
if m: ver[0] = m.group(1)
r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
if r:
m = lastNum.search(i)
if m: ver[1] = m.group(1)
r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
if r:
m = lastNum.search(i)
if m: ver[2] = m.group(1)
f.close()
com.cmd("git checkout master")
os.chdir("../")
return ver
def push(c):
return
cmd(c)
def update_version(ver):
ver_str = ver_format(ver)
ver_num = ver[0] + "." + ver[1] + "." + ver[2]
templ = fnmatch.filter(os.listdir('.'), '*_templ*.h')
if len(templ) > 0 and templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ "v" + ver_num + "/' " + templ[0])
if os.path.exists("library.json"):
print("Updating version in library.json")
cmd("sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+/"+ ver_num +"/' library.json")
if path.exists("library.properties"):
print("Updating version in library.properties")
cmd("sed -i -r 's/version=[0-9]+\.[0-9]+\.[0-9]+/"+ "version=" + ver_num + "/' library.properties")
if path.exists("conf.py"):
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py")
if path.exists("lvgl.h"):
define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver[0]))
define_set("./lvgl.h", "LVGL_VERSION_MINOR", str(ver[1]))
define_set("./lvgl.h", "LVGL_VERSION_PATCH", str(ver[2]))
define_set("./lvgl.h", "LVGL_VERSION_INFO", "\"" + ver[3] + "\"")

74
scripts/release/dev.py Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env python
import re
import os, fnmatch
import os.path
from os import path
from datetime import date
import com
def lvgl_upadte_ver(ver, br):
os.chdir("./lvgl")
com.cmd("git checkout " + br)
com.update_version(ver)
com.cmd("git commit -am 'Update " + br + " version'")
com.push("origin " + br)
com.cmd("git checkout master")
os.chdir("../")
def docs_update_ver(ver, br):
os.chdir("./docs")
com.cmd("git checkout " + br + " --")
com.update_version(ver)
com.cmd("git commit -am 'Update " + br + " version'")
com.push("origin " + br)
com.cmd("git checkout master --")
os.chdir("../")
def merge_dev_to_master():
os.chdir("./lvgl")
com.cmd("git checkout master")
com.cmd("git merge dev")
com.push("origin master")
os.chdir("../")
os.chdir("./docs")
com.cmd("git checkout dev -- ") #'dev' sometimes is not recognized so switch to it first
com.cmd("git checkout latest --")
com.cmd("git merge dev -X theirs --no-edit;")
com.push("origin latest")
os.chdir("../")
def make(mode):
ver = com.get_lvgl_version("dev")
ver[3] = "dev"
if(mode == "bugfix"):
ver[2] = ver[2] + 1
lvgl_update_ver(ver, "master")
docs_update_ver(ver, "latest")
else:
merge_dev_to_master()
if(mode == "major"):
ver[0] = str(int(ver[0]) + 1)
ver[1] = '0'
ver[2] = '0'
if(mode == "minor"):
ver[1] = str(int(ver[1]) + 1)
ver[2] = '0'
lvgl_upadte_ver(ver, "dev")
docs_update_ver(ver, "dev")
if __name__ == '__main__':
if(len(sys.argv) != 2):
print("Missing argument. Usage ./dev.py major | minor | bugfix")
print("E.g. ./dev.py minor")
else:
make(sys.argv[1])

64
scripts/release/main.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env python
import os.path
from os import path
from datetime import date
import sys
import com
import release
import dev
import proj
upstream_org_url = "https://github.com/lvgl/"
workdir = "./release_tmp"
proj_list = [ "lv_sim_eclipse_sdl", "lv_sim_emscripten"]
def upstream(repo):
return upstream_org_url + repo + ".git"
def clone(repo):
com.cmd("git clone --recurse-submodules " + upstream(repo))
os.chdir("./" + repo)
com.cmd("git checkout master")
com.cmd("git remote update origin --prune")
com.cmd("git pull origin --tags")
os.chdir("..")
def clone_repos():
com.cmd("rm -fr " + workdir)
com.cmd("mkdir " + workdir)
os.chdir(workdir)
clone("lvgl")
clone("lv_examples")
clone("lv_drivers")
clone("docs")
clone("blog")
for p in proj_list:
clone(p)
def cleanup():
os.chdir("../")
com.cmd("rm -fr " + workdir)
if __name__ == '__main__':
prepare_type = ['major', 'minor', 'bugfix']
dev_prepare = 'minor'
# if(len(sys.argv) != 2):
# print("Missing argument. Usage ./release.py bugfix | minor | major")
# print("Use minor by deafult")
# else:
# dev_prepare = sys.argv[1]
if not (dev_prepare in prepare_type):
print("Invalid argument. Usage ./release.py bugfix | minor | major")
exit(1)
clone_repos()
release.make()
for p in proj_list:
proj.make(p, True)
dev.make(dev_prepare)
#cleanup()

64
scripts/release/proj.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env python
import sys
import os.path
from os import path
import re
import subprocess
import com
def make(repo_path, auto_push = False):
os.chdir("./" + repo_path)
com.cmd('git checkout master')
print("Upadte lvgl");
os.chdir("./lvgl")
com.cmd("git checkout master")
com.cmd("git pull origin --tags")
out = subprocess.Popen(['git', 'tag', '--sort=-creatordate'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout,stderr = out.communicate()
ver_str = stdout.decode("utf-8").split('\n')[0]
release_br = ver_str[1:] #trim "v"
release_br = release_br.split('.')[0] # get the first number
release_br = "release/v" + release_br
com.cmd("git checkout " + release_br + "; git pull origin " + release_br)
os.chdir("..")
com.cmd("cp -f lvgl/lv_conf_template.h lv_conf.h")
com.cmd("sed -i -r 's/#if 0/#if 1/' lv_conf.h") # Enable lv_conf.h
with open("confdef.txt") as f:
for line in f:
(key, val) = line.rstrip().split('\t')
com.define_set("lv_conf.h", str(key), str(val))
if os.path.exists("lv_examples"):
print("Upadte lv_examples");
com.cmd("cd lv_examples; git co " + release_br + "; git pull origin " + release_br)
if os.path.exists("lv_drivers"):
print("upadte lv_drivers");
com.cmd("cd lv_drivers " + release_br + "; git pull origin " + release_br)
msg = 'Update to ' + ver_str
com.cmd("git add .")
com.cmd('git commit -am "' + msg + '"')
com.cmd("git tag -a " + ver_str + " -m '" + msg + "' " )
if auto_push:
com.push("origin --tags")
com.push("origin master")
os.chdir("../")
if __name__ == '__main__':
if(len(sys.argv) != 2):
print("Missing argument. Usage ./projs_update.py repo_path")
print("E.g. ./projs_update.py ./lv_sim_eclipse_sdl")
else:
make(sys.argv[1], sys.argv[2])

173
scripts/release/release.py Executable file
View File

@ -0,0 +1,173 @@
#!/usr/bin/env python
import os.path
from os import path
from datetime import date
import sys
import com
import re
def update_release_branch(release_br, master_br = "master"):
com.cmd("git checkout " + release_br)
com.cmd("git pull origin " + release_br)
com.cmd("git merge "+ master_br +" -X ours");
com.push("origin " + release_br);
com.cmd("git checkout master");
def lvgl_release(ver):
print("Release lvgl")
ver_str = com.ver_format(ver)
release_br = "release/v" + str(ver[0])
os.chdir("./lvgl")
com.define_set("./lvgl.h", "LVGL_VERSION_INFO", '\"\"')
# Run some scripts
os.chdir("./scripts")
com.cmd("./code-format.sh")
com.cmd("./lv_conf_checker.py")
com.cmd("doxygen")
os.chdir("../")
com.update_version(ver)
#update CHANGLELOG
new_content = ""
f = open("./CHANGELOG.md", "r")
release_note = ""
note_state = 0
for i in f.read().splitlines():
if note_state == 0:
r = re.search(r'^## ' + ver_str, i)
if r:
i = i.replace("planned on ", "")
note_state+=1
elif note_state == 1:
r = re.search(r'^## ', i)
if r:
note_state+=1
else:
release_note += i + '\n'
new_content += i + '\n'
f.close()
f = open("./CHANGELOG.md", "w")
f.write(new_content)
f.close()
com.cmd('git commit -am "Release ' + ver_str + '"')
com.cmd('git checkout dev')
com.cmd("git merge master -X ours")
com.cmd("git add .")
com.cmd("git commit -am 'Merge master'", False)
com.push('origin dev')
com.cmd('git checkout master')
com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ")
com.push('origin master')
com.push('origin --tags')
update_release_branch(release_br)
os.chdir("../")
return release_note
def lv_examples_release(ver):
print("Release lv_examples")
os.chdir("./lv_examples")
release_br = "release/v" + str(ver[0])
ver_str = com.ver_format(ver)
com.update_version(ver)
com.cmd("sed -i -r 's/LV_VERSION_CHECK\([0-9]+, *[0-9]+, *[0-9]+\)/"+ "LV_VERSION_CHECK(" + str(ver[0]) + ", " + str(ver[1]) + ", " + str(ver[2]) + ")/' lv_examples.h")
com.cmd('git commit -am "Release ' + ver_str + '"')
com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ")
com.push('origin master')
com.push('origin --tags')
os.chdir("../")
def lv_drivers_release(ver):
print("Release lv_drivers")
os.chdir("./lv_drivers")
release_br = "release/v" + str(ver[0])
ver_str = com.ver_format(ver)
com.update_version(ver)
com.cmd('git commit -am "Release ' + ver_str + '"')
com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ")
com.push('origin master')
com.push('origin --tags')
update_release_branch(release_br)
os.chdir("../")
def docs_release(ver):
print("Release docs")
os.chdir("./docs")
release_br = "release/v" + str(ver[0])
ver_str = com.ver_format(ver)
com.cmd("git co latest --")
com.cmd("rm -rf xml");
com.cmd("cp -r ../lvgl/docs/api_doc/xml .");
com.cmd("git add xml");
com.update_version(ver)
com.cmd('git commit -am "Release ' + ver_str + '"')
com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ")
com.push('origin master')
com.push('origin --tags')
update_release_branch(release_br, "latest")
os.chdir("../")
def blog_release(ver, release_note):
os.chdir("./blog/_posts")
ver_str = com.ver_format(ver)
post = "---\nlayout: post\ntitle: " + ver_str + " is released\nauthor: \"kisvegabor\"\ncover: /assets/release_cover.png\n---\n\n"
post += release_note
today = date.today()
d = today.strftime("%Y-%m-%d")
f = open(d + "-release_" + ver_str + ".md", "w")
f.write(post)
f.close()
com.cmd("git add .")
com.cmd("git commit -am 'Add " + ver_str + " release post'")
com.push('origin master')
os.chdir("../../")
def make():
ver = com.get_lvgl_version("master")
release_note = lvgl_release(ver)
lv_examples_release(ver)
lv_drivers_release(ver)
docs_release(ver)
blog_release(ver, release_note)
if __name__ == '__main__':
make()

View File

@ -25,8 +25,12 @@
# endif
#endif
/* clang-format off */
/*Handle special Kconfig options*/
#include "lv_conf_kconfig.h"
#include <stdint.h>
/*====================
@ -478,7 +482,11 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
/*1: Use PXP for CPU off-load on NXP RTxxx platforms */
#ifndef LV_USE_GPU_NXP_PXP
#define LV_USE_GPU_NXP_PXP 0
# 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)
@ -487,7 +495,20 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
*0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init()
* */
#ifndef LV_USE_GPU_NXP_PXP_AUTO_INIT
#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0
# 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 */
@ -614,9 +635,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
@ -1265,7 +1297,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
/* Support bidirectional texts.
* Allows mixing Left-to-Right and Right-to-Left texts.
* The direction will be processed according to the Unicode Bidirectional Algorithm:
* The direction will be processed according to the Unicode Bidirectioanl Algorithm:
* https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
#ifndef LV_USE_BIDI
# ifdef CONFIG_LV_USE_BIDI
@ -1680,7 +1712,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
/*==================
* Non-user section

294
src/lv_conf_kconfig.h Normal file
View File

@ -0,0 +1,294 @@
/**
* @file lv_conf_kconfig.h
* Configs that needs special handling when LVGL is used with Kconfig
*/
#ifndef LV_CONF_KCONFIG_H
#define LV_CONF_KCONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/*******************
* THEME SELECTION
*******************/
#ifndef LV_THEME_DEFAULT_INIT
#if defined (CONFIG_LV_THEME_DEFAULT_INIT_EMPTY)
#define LV_THEME_DEFAULT_INIT lv_theme_empty_init
#elif defined (CONFIG_LV_THEME_DEFAULT_INIT_TEMPLATE)
#define LV_THEME_DEFAULT_INIT lv_theme_template_init
#elif defined (CONFIG_LV_THEME_DEFAULT_INIT_MATERIAL)
#define LV_THEME_DEFAULT_INIT lv_theme_material_init
#elif defined (CONFIG_LV_THEME_DEFAULT_INIT_MONO)
#define LV_THEME_DEFAULT_INIT lv_theme_mono_init
#endif
#endif
/*******************
* COLOR SELECTION
*******************/
#ifdef LV_THEME_DEFAULT_COLOR_PRIMARY
#ifdef CONFIG_LV_THEME_DEFAULT_COLOR_PRIMARY
#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(CONFIG_LV_THEME_DEFAULT_COLOR_PRIMARY)
#endif
#endif
#ifdef LV_THEME_DEFAULT_COLOR_SECONDARY
#ifdef CONFIG_LV_THEME_DEFAULT_COLOR_SECONDARY
#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(CONFIG_LV_THEME_DEFAULT_COLOR_SECONDARY)
#endif
#endif
/********************
* FONT SELECTION
*******************/
/* NOTE: In Kconfig instead of `LV_THEME_DEFAULT_FONT_SMALL`
* `CONFIG_LV_THEME_DEFAULT_FONT_SMALL_<font_name>` is defined
* hence the large selection with if-s
*/
/*------------------
* SMALL FONT
*-----------------*/
#ifndef LV_THEME_DEFAULT_FONT_SMALL
#if defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_8
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_8
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_10
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_10
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_12
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_12
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_14
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_16
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_18
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_18
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_20
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_20
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_22
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_22
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_24
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_24
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_26
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_26
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_28
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_28
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_30
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_30
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_32
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_32
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_34
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_34
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_36
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_36
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_38
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_38
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_40
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_40
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_42
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_42
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_44
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_44
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_46
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_46
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT_48
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_48
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_UNSCII_8
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_unscii_8
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT12SUBPX
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_12_subpx
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_MONTSERRAT28COMPRESSED
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_28_compressed
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_DEJAVU_16_PERSIAN_HEBREW
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_dejavu_16_persian_hebrew
#elif defined CONFIG_LV_FONT_DEFAULT_SMALL_SIMSUN_16_CJK
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_simsun_16_cjk
#endif
#endif
/*------------------
* NORMAL FONT
*-----------------*/
#ifndef LV_THEME_DEFAULT_FONT_NORMAL
#if defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_8
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_8
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_10
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_10
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_12
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_12
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_14
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_16
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_18
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_18
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_20
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_20
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_22
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_22
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_24
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_24
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_26
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_26
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_28
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_28
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_30
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_30
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_32
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_32
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_34
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_34
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_36
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_36
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_38
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_38
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_40
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_40
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_42
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_42
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_44
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_44
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_46
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_46
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT_48
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_48
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_UNSCII_8
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_unscii_8
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT12SUBPX
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_12_subpx
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_MONTSERRAT28COMPRESSED
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_28_compressed
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_DEJAVU_16_PERSIAN_HEBREW
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_dejavu_16_persian_hebrew
#elif defined CONFIG_LV_FONT_DEFAULT_NORMAL_SIMSUN_16_CJK
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_simsun_16_cjk
#endif
#endif
/*------------------
* SUBTITLE FONT
*-----------------*/
#ifndef LV_THEME_DEFAULT_FONT_SUBTITLE
#if defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_8
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_8
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_10
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_10
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_12
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_12
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_14
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_16
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_18
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_18
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_20
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_20
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_22
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_22
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_24
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_24
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_26
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_26
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_28
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_28
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_30
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_30
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_32
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_32
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_34
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_34
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_36
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_36
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_38
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_38
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_40
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_40
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_42
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_42
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_44
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_44
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_46
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_46
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT_48
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_48
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_UNSCII_8
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_unscii_8
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT12SUBPX
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_12_subpx
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_MONTSERRAT28COMPRESSED
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_28_compressed
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_DEJAVU_16_PERSIAN_HEBREW
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_dejavu_16_persian_hebrew
#elif defined CONFIG_LV_FONT_DEFAULT_SUBTITLE_SIMSUN_16_CJK
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_simsun_16_cjk
#endif
#endif
/*------------------
* TITLE FONT
*-----------------*/
#ifndef LV_THEME_DEFAULT_FONT_TITLE
#if defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_8
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_8
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_10
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_10
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_12
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_12
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_14
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_16
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_18
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_18
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_20
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_20
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_22
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_22
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_24
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_24
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_26
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_26
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_28
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_28
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_30
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_30
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_32
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_32
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_34
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_34
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_36
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_36
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_38
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_38
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_40
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_40
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_42
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_42
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_44
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_44
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_46
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_46
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT_48
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_48
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_UNSCII_8
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_unscii_8
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT12SUBPX
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_12_subpx
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_MONTSERRAT28COMPRESSED
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_28_compressed
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_DEJAVU_16_PERSIAN_HEBREW
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_dejavu_16_persian_hebrew
#elif defined CONFIG_LV_FONT_DEFAULT_TITLE_SIMSUN_16_CJK
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_simsun_16_cjk
#endif
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_CONF_KCONFIG_H*/

View File

@ -316,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

@ -484,6 +484,7 @@ 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_STATE_DISABLED) continue;
/*Hidden objects don't receive focus*/
if(lv_obj_has_flag(*obj_next, LV_OBJ_FLAG_HIDDEN) == false) break;

View File

@ -1084,14 +1084,14 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_CLICK_FOCUSABLE) &&
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*/
@ -1140,7 +1140,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 {
@ -1158,9 +1158,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

@ -473,6 +473,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

@ -162,14 +162,15 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_FONT, 0x7, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_STR, 0x7, LV_STYLE_ID_PTR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_DECOR, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT),
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_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),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_DECOR, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT),
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),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_WIDTH, 0x9, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_BLEND_MODE, 0x9, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),

View File

@ -13,9 +13,11 @@
#include "../lv_core/lv_refr.h"
#if LV_USE_GPU_NXP_PXP
#include "../lv_gpu/lv_gpu_nxp_pxp.h"
#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"
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#endif
/*********************
@ -341,10 +343,17 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
return;
}
#elif LV_USE_GPU_NXP_PXP
if(lv_area_get_size(draw_area) >= GPU_NXP_PXP_FILL_SIZE_LIMIT) {
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);
@ -361,10 +370,17 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
else {
#if LV_USE_GPU_NXP_PXP
if(lv_area_get_size(draw_area) >= GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT) {
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;
@ -385,6 +401,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
lv_coord_t line_h = LV_HOR_RES_MAX / draw_area_w;
for(y = 0; y <= draw_area_h - line_h; y += line_h) {
lv_gpu_stm32_dma2d_blend(disp_buf_first, disp_w, blend_buf, opa, draw_area_w, draw_area_w, line_h);
lv_gpu_stm32_dma2d_wait_cb(NULL);
disp_buf_first += disp_w * line_h;
}
@ -741,15 +758,46 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
if(opa > LV_OPA_MAX) {
#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;
}
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;
}
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;
}
#endif
/*Software rendering*/
@ -761,10 +809,41 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
}
else {
#if LV_USE_GPU_NXP_PXP
if (lv_area_get_size(draw_area) >= GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT) {
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);

View File

@ -14,9 +14,9 @@
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_math.h"
#if LV_USE_GPU_STM32_DMA2D
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#elif LV_USE_GPU_NXP_PXP
#include "../lv_gpu/lv_gpu_nxp_pxp.h"
#include "../lv_gpu/lv_gpu_nxp_pxp.h"
#endif
/*********************
@ -360,18 +360,19 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
}
#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 &&
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 &&
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();
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*/
@ -418,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);
@ -468,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

@ -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,18 +1335,30 @@ 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 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);
if(rout > short_side >> 1) rout = short_side >> 1;
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*/
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);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
* INCLUDES
*********************/
#include "lv_conf.h"
#include "../lv_conf_internal.h"
#if LV_USE_GPU_NXP_PXP
@ -48,9 +48,6 @@
* DEFINES
*********************/
/* PXP instance ID */
#define PXP_ID PXP
#if LV_COLOR_16_SWAP
#error Color swap not implemented. Disable LV_COLOR_16_SWAP feature.
#endif
@ -76,7 +73,8 @@ 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 void lv_gpu_nxp_invalidate_cache(uint32_t address, uint32_t width, uint32_t height, uint32_t stride,
uint32_t pxSize);
/**********************
* STATIC VARIABLES
@ -135,7 +133,7 @@ void lv_gpu_nxp_pxp_deinit(void)
{
pxp_cfg.pxp_interrupt_deinit();
PXP_DisableInterrupts(PXP, kPXP_CompleteInterruptEnable);
PXP_Deinit(PXP_ID);
PXP_Deinit(LV_GPU_NXP_PXP_ID);
}
@ -151,8 +149,8 @@ void lv_gpu_nxp_pxp_deinit(void)
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(PXP_ID);
PXP_EnableCsc1(PXP_ID, false); /* Disable CSC1, it is enabled by default. */
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 */
@ -165,14 +163,15 @@ void lv_gpu_nxp_pxp_fill(lv_color_t * dest_buf, lv_coord_t dest_width, const lv_
.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(PXP_ID, &outputConfig);
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(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U); /* Disable AS. */
PXP_SetProcessSurfacePosition(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U); /* Disable PS. */
PXP_SetProcessSurfaceBackGroundColor(PXP_ID, lv_color_to32(color));
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 */
@ -184,12 +183,13 @@ void lv_gpu_nxp_pxp_fill(lv_color_t * dest_buf, lv_coord_t dest_width, const lv_
asBufferConfig.bufferAddr = (uint32_t)outputConfig.buffer0Addr;
asBufferConfig.pitchBytes = outputConfig.pitchBytes;
PXP_SetAlphaSurfaceBufferConfig(PXP_ID, &asBufferConfig);
PXP_SetAlphaSurfacePosition(PXP_ID, 0U, 0U, fill_area->x2 - fill_area->x1 + 1, fill_area->y2 - fill_area->y1 + 1);
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(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U);
PXP_SetProcessSurfaceBackGroundColor(PXP_ID, lv_color_to32(color));
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;
@ -203,7 +203,7 @@ void lv_gpu_nxp_pxp_fill(lv_color_t * dest_buf, lv_coord_t dest_width, const lv_
pdConfig.dstGlobalAlpha = 255 - opa;
pdConfig.srcAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
pdConfig.dstAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
PXP_SetPorterDuffConfig(PXP_ID, &pdConfig);
PXP_SetPorterDuffConfig(LV_GPU_NXP_PXP_ID, &pdConfig);
}
lv_gpu_nxp_pxp_run(); /* Start PXP task */
@ -249,7 +249,7 @@ void lv_gpu_nxp_pxp_blit(lv_color_t * dest, lv_coord_t dest_width, const lv_colo
if(opa >= LV_OPA_MAX && !colorKeyEnabled) {
/* Simple blit, no effect - Disable PS buffer */
PXP_SetProcessSurfacePosition(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U);
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
@ -263,24 +263,25 @@ void lv_gpu_nxp_pxp_blit(lv_color_t * dest, lv_coord_t dest_width, const lv_colo
.pitchBytes = dest_width * sizeof(lv_color_t)
};
asBlendConfig.alphaMode = kPXP_AlphaOverride;
PXP_SetProcessSurfaceBufferConfig(PXP_ID, &psBufferConfig);
PXP_SetProcessSurfacePosition(PXP_ID, 0U, 0U, copy_width - 1, copy_height - 1);
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(PXP_ID, &asBufferConfig);
PXP_SetAlphaSurfacePosition(PXP_ID, 0U, 0U, copy_width - 1U, copy_height - 1U);
PXP_SetAlphaSurfaceBlendConfig(PXP_ID, &asBlendConfig);
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));
lv_gpu_nxp_invalidate_cache(asBufferConfig.bufferAddr, copy_width, copy_height, asBufferConfig.pitchBytes,
sizeof(lv_color_t));
if(colorKeyEnabled) {
PXP_SetAlphaSurfaceOverlayColorKey(PXP_ID, colorKey, colorKey);
PXP_SetAlphaSurfaceOverlayColorKey(LV_GPU_NXP_PXP_ID, colorKey, colorKey);
}
PXP_EnableAlphaSurfaceOverlayColorKey(PXP_ID, colorKeyEnabled);
PXP_EnableAlphaSurfaceOverlayColorKey(LV_GPU_NXP_PXP_ID, colorKeyEnabled);
/* Output buffer. */
@ -291,9 +292,10 @@ void lv_gpu_nxp_pxp_blit(lv_color_t * dest, lv_coord_t dest_width, const lv_colo
outputBufferConfig.pitchBytes = dest_width * sizeof(lv_color_t);
outputBufferConfig.width = copy_width;
outputBufferConfig.height = copy_height;
PXP_SetOutputBufferConfig(PXP_ID, &outputBufferConfig);
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_invalidate_cache(outputBufferConfig.buffer0Addr, outputBufferConfig.width, outputBufferConfig.height,
outputBufferConfig.pitchBytes, sizeof(lv_color_t));
lv_gpu_nxp_pxp_run(); /* Start PXP task */
}
@ -395,14 +397,15 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width
asBufferConfig.pixelFormat = PXP_AS_PIXEL_FORMAT;
asBufferConfig.bufferAddr = (uint32_t)src;
asBufferConfig.pitchBytes = src_width * sizeof(lv_color_t);
PXP_SetAlphaSurfaceBufferConfig(PXP_ID, &asBufferConfig);
PXP_SetAlphaSurfacePosition(PXP_ID, 0U, 0U, copy_width - 1U, copy_height - 1U);
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));
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(PXP_ID, 0xFFFFU, 0xFFFFU, 0U, 0U);
PXP_SetProcessSurfaceBackGroundColor(PXP_ID, lv_color_to32(recolor));
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;
@ -412,9 +415,10 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width
outputBufferConfig.pitchBytes = dest_width * sizeof(lv_color_t);
outputBufferConfig.width = copy_width;
outputBufferConfig.height = copy_height;
PXP_SetOutputBufferConfig(PXP_ID, &outputBufferConfig);
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_invalidate_cache(outputBufferConfig.buffer0Addr, outputBufferConfig.width, outputBufferConfig.height,
outputBufferConfig.pitchBytes, sizeof(lv_color_t));
pxp_porter_duff_config_t pdConfig;
@ -430,7 +434,7 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width
pdConfig.dstGlobalAlpha = 255 - recolorOpa;
pdConfig.srcAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
pdConfig.dstAlphaMode = kPXP_PorterDuffAlphaStraight; /* don't care */
PXP_SetPorterDuffConfig(PXP_ID, &pdConfig);
PXP_SetPorterDuffConfig(LV_GPU_NXP_PXP_ID, &pdConfig);
lv_gpu_nxp_pxp_run(); /* Start PXP task */
@ -463,11 +467,13 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width
* @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) {
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);
for(y = 0; y < height; y++) {
DCACHE_CleanInvalidateByRange(address, width * pxSize);
address += stride;
}
}

View File

@ -45,30 +45,30 @@ extern "C" {
* DEFINES
*********************/
/* PXP module instance to use */
#define PXP_ID PXP
/** PXP module instance to use */
#define LV_GPU_NXP_PXP_ID PXP
/* PXP interrupt line ID */
#define PXP_IRQ_ID PXP_IRQn
/** PXP interrupt line ID */
#define LV_GPU_NXP_PXP_IRQ_ID PXP_IRQn
/* Minimum area for image copy with 100% opacity to be handled by PXP */
#ifndef GPU_NXP_PXP_BLIT_SIZE_LIMIT
#define GPU_NXP_PXP_BLIT_SIZE_LIMIT 1
#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
/* Minimum area for image copy with transparency to be handled by PXP */
#ifndef GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT
#define GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT 16
#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
/* Minimum area to be filled by PXP with 100% opacity */
#ifndef GPU_NXP_PXP_FILL_SIZE_LIMIT
#define GPU_NXP_PXP_FILL_SIZE_LIMIT 64
#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
/* Minimum area to be filled by PXP with transparency */
#ifndef GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT
#define GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT 32
#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
/**********************
@ -107,7 +107,7 @@ typedef struct {
*
* @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);
lv_res_t lv_gpu_nxp_pxp_init(lv_nxp_pxp_cfg_t * cfg);
/**
* Disable PXP device. Should be called during display deinit sequence.
@ -123,7 +123,8 @@ void lv_gpu_nxp_pxp_deinit(void);
* @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);
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);
@ -143,7 +144,8 @@ void lv_gpu_nxp_pxp_fill(lv_color_t *dest_buf, lv_coord_t dest_width, const lv_a
* @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);
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);
/**

View File

@ -31,7 +31,7 @@
* INCLUDES
*********************/
#include "lv_conf.h"
#include "../lv_conf_internal.h"
#if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
@ -86,8 +86,8 @@ void PXP_IRQHandler(void)
BaseType_t taskAwake = pdFALSE;
#endif
if(kPXP_CompleteFlag & PXP_GetStatusFlags(PXP_ID)) {
PXP_ClearStatusFlags(PXP_ID, kPXP_CompleteFlag);
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);
@ -113,12 +113,12 @@ static lv_res_t _lv_gpu_nxp_pxp_interrupt_init(void)
return LV_RES_INV;
}
NVIC_SetPriority(PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1);
NVIC_SetPriority(LV_GPU_NXP_PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1);
#else
s_pxpIdle = true;
#endif
NVIC_EnableIRQ(PXP_IRQ_ID);
NVIC_EnableIRQ(LV_GPU_NXP_PXP_IRQ_ID);
return LV_RES_OK;
}
@ -128,7 +128,7 @@ static lv_res_t _lv_gpu_nxp_pxp_interrupt_init(void)
*/
static void _lv_gpu_nxp_pxp_interrupt_deinit(void)
{
NVIC_DisableIRQ(PXP_IRQ_ID);
NVIC_DisableIRQ(LV_GPU_NXP_PXP_IRQ_ID);
#if defined(FSL_RTOS_FREE_RTOS)
vSemaphoreDelete(s_pxpIdle);
#endif
@ -143,8 +143,8 @@ static void _lv_gpu_nxp_pxp_run(void)
s_pxpIdle = false;
#endif
PXP_EnableInterrupts(PXP_ID, kPXP_CompleteInterruptEnable);
PXP_Start(PXP_ID);
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) {

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_internal.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

@ -43,7 +43,7 @@
* STATIC PROTOTYPES
**********************/
static void invalidate_cache(void);
static void dma2d_wait(void);
static void wait_finish(void);
/**********************
* STATIC VARIABLES
@ -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;
@ -95,7 +104,7 @@ void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t colo
/* start transfer */
DMA2D->CR |= DMA2D_CR_START_Msk;
dma2d_wait();
wait_finish();
}
/**
@ -140,7 +149,7 @@ void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t
HAL_DMA2D_ConfigLayer(&hdma2d, 0);
HAL_DMA2D_ConfigLayer(&hdma2d, 1);
HAL_DMA2D_BlendingStart(&hdma2d, (uint32_t) mask, (uint32_t) buf, (uint32_t)buf, fill_w, fill_h);
dma2d_wait();
wait_finish();
#endif
}
@ -170,7 +179,7 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_
/* start transfer */
DMA2D->CR |= DMA2D_CR_START_Msk;
dma2d_wait();
wait_finish();
}
/**
@ -208,7 +217,18 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color
/* start transfer */
DMA2D->CR |= DMA2D_CR_START_Msk;
dma2d_wait();
wait_finish();
}
void lv_gpu_stm32_dma2d_wait_cb(lv_disp_drv_t * drv)
{
if(drv && drv->wait_cb) {
while(DMA2D->CR & DMA2D_CR_START_Msk) {
drv->wait_cb(drv);
}
} else {
while(DMA2D->CR & DMA2D_CR_START_Msk);
}
}
/**********************
@ -226,9 +246,11 @@ static void invalidate_cache(void)
}
}
static void dma2d_wait(void)
static void wait_finish(void)
{
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
if(disp->driver.gpu_wait_cb) return;
while(DMA2D->CR & DMA2D_CR_START_Msk) {
if(disp->driver.wait_cb) disp->driver.wait_cb(&disp->driver);
}

View File

@ -15,6 +15,7 @@ extern "C" {
*********************/
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_color.h"
#include "../lv_hal/lv_hal_disp.h"
/*********************
* DEFINES
@ -91,6 +92,14 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_
*/
void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_opa_t opa,
lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h);
/**
* Can be used as `gpu_wait_cb` in display driver to
* let the MCU run while the GPU is working
*/
void lv_gpu_stm32_dma2d_wait_cb(lv_disp_drv_t * drv);
/**********************
* MACROS
**********************/

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

@ -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)
@ -215,7 +215,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);
@ -228,7 +229,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);
@ -561,10 +561,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);
@ -855,7 +857,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));
@ -1261,27 +1262,32 @@ 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);
<<<<<<< HEAD
list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
=======
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);
>>>>>>> dev
_lv_style_list_add_style(list, &styles->chart_series);
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
{
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->sb);
case LV_THEME_TABLE: {
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
int idx = 1; /* start value should be 1, not zero, since cell styles
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);
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;
}
break;
}
#endif
#if LV_USE_WIN

View File

@ -114,6 +114,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);
@ -863,22 +865,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:
{
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
case LV_THEME_TABLE: {
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
int idx = 1; /* start value should be 1, not zero, since cell styles
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);
/* 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;
}
break;
}
#endif
#if LV_USE_WIN

View File

@ -716,21 +716,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:
{
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
case LV_THEME_TABLE: {
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
int idx = 1; /* start value should be 1, not zero, since cell styles
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);
/* 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;
}
break;
}
#endif
#if LV_USE_WIN

1091
src/lv_widgets/lv_calendar.c Normal file

File diff suppressed because it is too large Load Diff

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
@ -1359,7 +1621,9 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
/* set the area at some distance of the major tick len left of the tick */
/* 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;
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;
@ -1498,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;
@ -1535,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);
@ -1553,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
*====================*/

805
src/lv_widgets/lv_cont.c Normal file
View File

@ -0,0 +1,805 @@
/**
* @file lv_cont.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_cont.h"
#if LV_USE_CONT != 0
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "../lv_misc/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_draw/lv_draw_mask.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_math.h"
/*********************
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_cont"
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param);
static lv_style_list_t * lv_cont_get_style(lv_obj_t * cont, uint8_t type);
static void lv_cont_refr_layout(lv_obj_t * cont);
static void lv_cont_layout_col(lv_obj_t * cont);
static void lv_cont_layout_row(lv_obj_t * cont);
static void lv_cont_layout_center(lv_obj_t * cont);
static void lv_cont_layout_pretty(lv_obj_t * cont);
static void lv_cont_layout_grid(lv_obj_t * cont);
static void lv_cont_refr_autofit(lv_obj_t * cont);
/**********************
* STATIC VARIABLES
**********************/
static lv_design_cb_t ancestor_design;
static lv_signal_cb_t ancestor_signal;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create a container objects
* @param par pointer to an object, it will be the parent of the new container
* @param copy pointer to a container object, if not NULL then the new object will be copied from it
* @return pointer to the created container
*/
lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("container create started");
/*Create a basic object*/
lv_obj_t * cont = lv_obj_create(par, copy);
LV_ASSERT_MEM(cont);
if(cont == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(cont);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(cont);
lv_obj_allocate_ext_attr(cont, sizeof(lv_cont_ext_t));
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext == NULL) {
lv_obj_del(cont);
return NULL;
}
LV_ASSERT_MEM(ext);
ext->fit_left = LV_FIT_NONE;
ext->fit_right = LV_FIT_NONE;
ext->fit_top = LV_FIT_NONE;
ext->fit_bottom = LV_FIT_NONE;
ext->layout = LV_LAYOUT_OFF;
lv_obj_set_signal_cb(cont, lv_cont_signal);
/*Init the new container*/
if(copy == NULL) {
/*Set the default styles if it's not screen*/
if(par != NULL) {
lv_theme_apply(cont, LV_THEME_CONT);
}
}
/*Copy an existing object*/
else {
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->fit_left = copy_ext->fit_left;
ext->fit_right = copy_ext->fit_right;
ext->fit_top = copy_ext->fit_top;
ext->fit_bottom = copy_ext->fit_bottom;
ext->layout = copy_ext->layout;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(cont, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
LV_LOG_INFO("container created");
return cont;
}
/*=====================
* Setter functions
*====================*/
/**
* Set a layout on a container
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->layout == layout) return;
ext->layout = layout;
/*Send a signal to refresh the layout*/
cont->signal_cb(cont, LV_SIGNAL_CHILD_CHG, NULL);
}
/**
* Set the fit policy in all 4 directions separately.
* It tell how to change the container's size automatically.
* @param cont pointer to a container object
* @param left left fit policy from `lv_fit_t`
* @param right right fit policy from `lv_fit_t`
* @param top bottom fit policy from `lv_fit_t`
* @param bottom bottom fit policy from `lv_fit_t`
*/
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_obj_invalidate(cont);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->fit_left == left && ext->fit_right == right && ext->fit_top == top && ext->fit_bottom == bottom) {
return;
}
ext->fit_left = left;
ext->fit_right = right;
ext->fit_top = top;
ext->fit_bottom = bottom;
/*Send a signal to refresh the layout*/
cont->signal_cb(cont, LV_SIGNAL_CHILD_CHG, NULL);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the layout of a container
* @param cont pointer to container object
* @return the layout from 'lv_cont_layout_t'
*/
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->layout;
}
/**
* Get left fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->fit_left;
}
/**
* Get right fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->fit_right;
}
/**
* Get top fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->fit_top;
}
/**
* Get bottom fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
{
LV_ASSERT_OBJ(cont, LV_OBJX_NAME);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->fit_bottom;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Signal function of the container
* @param cont pointer to a container object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
{
if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
info->result = lv_cont_get_style(cont, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(cont, sign, param);
}
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(cont, sign, param);
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
if(sign == LV_SIGNAL_STYLE_CHG) { /*Recalculate the padding if the style changed*/
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
}
else if(sign == LV_SIGNAL_CHILD_CHG) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
}
else if(sign == LV_SIGNAL_COORD_CHG) {
if(lv_obj_get_width(cont) != lv_area_get_width(param) || lv_obj_get_height(cont) != lv_area_get_height(param)) {
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
}
}
else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
/*MAX and EDGE fit needs to be refreshed if the parent's size has changed*/
lv_cont_refr_autofit(cont);
}
return res;
}
static lv_style_list_t * lv_cont_get_style(lv_obj_t * cont, uint8_t type)
{
lv_style_list_t * style_dsc_p;
switch(type) {
case LV_CONT_PART_MAIN:
style_dsc_p = &cont->style_list;
break;
default:
style_dsc_p = NULL;
}
return style_dsc_p;
}
/**
* Refresh the layout of a container
* @param cont pointer to an object which layout should be refreshed
*/
static void lv_cont_refr_layout(lv_obj_t * cont)
{
if(lv_obj_is_protected(cont, LV_PROTECT_CHILD_CHG)) return;
lv_layout_t type = lv_cont_get_layout(cont);
/*'cont' has to be at least 1 child*/
if(lv_obj_get_child(cont, NULL) == NULL) return;
if(type == LV_LAYOUT_OFF) return;
if(type == LV_LAYOUT_CENTER) {
lv_cont_layout_center(cont);
}
else if(type == LV_LAYOUT_COLUMN_LEFT || type == LV_LAYOUT_COLUMN_MID || type == LV_LAYOUT_COLUMN_RIGHT) {
lv_cont_layout_col(cont);
}
else if(type == LV_LAYOUT_ROW_TOP || type == LV_LAYOUT_ROW_MID || type == LV_LAYOUT_ROW_BOTTOM) {
lv_cont_layout_row(cont);
}
else if(type == LV_LAYOUT_PRETTY_MID || type == LV_LAYOUT_PRETTY_TOP || type == LV_LAYOUT_PRETTY_BOTTOM) {
lv_cont_layout_pretty(cont);
}
else if(type == LV_LAYOUT_GRID) {
lv_cont_layout_grid(cont);
}
}
/**
* Handle column type layouts
* @param cont pointer to an object which layout should be handled
*/
static void lv_cont_layout_col(lv_obj_t * cont)
{
lv_coord_t left = lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);
lv_coord_t right = lv_obj_get_style_pad_right(cont, LV_CONT_PART_MAIN);
lv_coord_t top = lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child;
/*Adjust margin and get the alignment type*/
lv_align_t align;
lv_coord_t hpad_corr;
switch(type) {
case LV_LAYOUT_COLUMN_LEFT:
hpad_corr = left;
align = LV_ALIGN_IN_TOP_LEFT;
break;
case LV_LAYOUT_COLUMN_MID:
hpad_corr = 0;
align = LV_ALIGN_IN_TOP_MID;
break;
case LV_LAYOUT_COLUMN_RIGHT:
hpad_corr = -right;
align = LV_ALIGN_IN_TOP_RIGHT;
break;
default:
hpad_corr = 0;
align = LV_ALIGN_IN_TOP_LEFT;
break;
}
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_add_protect(cont, LV_PROTECT_CHILD_CHG);
/* Align the children */
lv_coord_t last_cord = top;
_LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_style_int_t mtop = lv_obj_get_style_margin_top(child, LV_OBJ_PART_MAIN);
lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(child, LV_OBJ_PART_MAIN);
lv_style_int_t mleft = lv_obj_get_style_margin_left(child, LV_OBJ_PART_MAIN);
lv_obj_align(child, cont, align, hpad_corr + mleft, last_cord + mtop);
last_cord += lv_obj_get_height(child) + inner + mtop + mbottom;
}
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}
/**
* Handle row type layouts
* @param cont pointer to an object which layout should be handled
*/
static void lv_cont_layout_row(lv_obj_t * cont)
{
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child;
/*Adjust margin and get the alignment type*/
lv_align_t align;
lv_coord_t vpad_corr;
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(cont);
switch(type) {
case LV_LAYOUT_ROW_TOP:
vpad_corr = lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_TOP_RIGHT : LV_ALIGN_IN_TOP_LEFT;
break;
case LV_LAYOUT_ROW_MID:
vpad_corr = 0;
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_RIGHT_MID : LV_ALIGN_IN_LEFT_MID;
break;
case LV_LAYOUT_ROW_BOTTOM:
vpad_corr = -lv_obj_get_style_pad_bottom(cont, LV_CONT_PART_MAIN);
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_BOTTOM_RIGHT : LV_ALIGN_IN_BOTTOM_LEFT;
break;
default:
vpad_corr = 0;
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_TOP_RIGHT : LV_ALIGN_IN_TOP_LEFT;
break;
}
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_add_protect(cont, LV_PROTECT_CHILD_CHG);
/* Align the children */
lv_coord_t last_cord;
if(base_dir == LV_BIDI_DIR_RTL) last_cord = lv_obj_get_style_pad_right(cont, LV_CONT_PART_MAIN);
else last_cord = lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
_LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
if(base_dir == LV_BIDI_DIR_RTL) lv_obj_align(child, cont, align, -last_cord, vpad_corr);
else lv_obj_align(child, cont, align, last_cord, vpad_corr);
last_cord += lv_obj_get_width(child) + inner;
}
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}
/**
* Handle the center layout
* @param cont pointer to an object which layout should be handled
*/
static void lv_cont_layout_center(lv_obj_t * cont)
{
lv_obj_t * child;
uint32_t obj_num = 0;
lv_coord_t h_tot = 0;
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
_LV_LL_READ(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
h_tot += lv_obj_get_height(child) + inner;
obj_num++;
}
if(obj_num == 0) return;
h_tot -= inner;
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_add_protect(cont, LV_PROTECT_CHILD_CHG);
/* Align the children */
lv_coord_t last_cord = -(h_tot / 2);
_LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
last_cord += lv_obj_get_height(child) + inner;
}
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}
/**
* Handle the pretty layout. Put as many object as possible in row
* then begin a new row
* @param cont pointer to an object which layout should be handled
*/
static void lv_cont_layout_pretty(lv_obj_t * cont)
{
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child_rs; /* Row starter child */
lv_obj_t * child_rc; /* Row closer child */
lv_obj_t * child_tmp; /* Temporary child */
lv_coord_t w_obj = lv_obj_get_width(cont);
lv_coord_t act_y = lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
child_rs = _lv_ll_get_tail(&cont->child_ll); /*Set the row starter child*/
if(child_rs == NULL) return; /*Return if no child*/
lv_obj_add_protect(cont, LV_PROTECT_CHILD_CHG);
lv_coord_t pleft = lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);
lv_coord_t pright = lv_obj_get_style_pad_right(cont, LV_CONT_PART_MAIN);
lv_coord_t pinner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
while(child_rs != NULL) {
lv_coord_t h_row = 0;
lv_coord_t w_row = pleft + pright; /*The width is at least the left+right pad*/
uint32_t obj_num = 0;
/*Find the row closer object and collect some data*/
do {
if(lv_obj_get_hidden(child_rc) == false && lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
/*If this object is already not fit then break*/
lv_coord_t w = lv_obj_get_width(child_rc);
w += lv_obj_get_style_margin_left(child_rc, LV_OBJ_PART_MAIN);
w += lv_obj_get_style_margin_right(child_rc, LV_OBJ_PART_MAIN);
if(w_row + w > w_obj) {
/*Step back one child because the last already not fit, so the previous is the
* closer*/
if(child_rc != NULL && obj_num != 0) {
child_rc = _lv_ll_get_next(&cont->child_ll, child_rc);
}
break;
}
w_row += w + pinner; /*Add the object width + inner padding*/
lv_coord_t h = lv_obj_get_height(child_rc);
h += lv_obj_get_style_margin_top(child_rc, LV_OBJ_PART_MAIN);
h += lv_obj_get_style_margin_bottom(child_rc, LV_OBJ_PART_MAIN);
h_row = LV_MATH_MAX(h_row, h); /*Search the highest object*/
obj_num++;
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW))
break; /*If can not be followed by an other object then break here*/
}
child_rc = _lv_ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
if(obj_num == 0)
child_rs = child_rc; /*If the first object was hidden (or too long) then set the
next as first */
} while(child_rc != NULL);
/*If the object is too long then align it to the middle*/
if(obj_num == 0) {
if(child_rc != NULL) {
lv_style_int_t mtop = lv_obj_get_style_margin_top(child_rc, LV_OBJ_PART_MAIN);
lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y + mtop);
h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/
h_row += mtop;
h_row += lv_obj_get_style_margin_bottom(child_rc, LV_OBJ_PART_MAIN);
}
}
/*If there is only one object in the row then align it to the middle*/
else if(obj_num == 1) {
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID,
0,
act_y + lv_obj_get_style_margin_top(child_rs, LV_OBJ_PART_MAIN));
}
/* Align the children (from child_rs to child_rc)*/
else {
w_row -= pinner * obj_num;
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, 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, 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, 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:
break;
}
act_x += lv_obj_get_width(child_tmp) + new_pinner + mleft + mright;
}
if(child_tmp == child_rc) break;
child_tmp = _lv_ll_get_prev(&cont->child_ll, child_tmp);
}
}
if(child_rc == NULL) break;
act_y += pinner + h_row; /*y increment*/
child_rs = _lv_ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
child_rc = child_rs;
}
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}
/**
* Handle the grid layout. Align same-sized objects in a grid
* @param cont pointer to an object which layout should be handled
*/
static void lv_cont_layout_grid(lv_obj_t * cont)
{
lv_coord_t w_fit = lv_obj_get_width_fit(cont);
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
lv_coord_t y_ofs = inner + lv_obj_get_height(lv_obj_get_child(cont, NULL));
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
lv_obj_add_protect(cont, LV_PROTECT_CHILD_CHG);
/* Align the children */
lv_coord_t left = lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);
lv_coord_t act_x = left;
lv_coord_t act_y = lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
lv_obj_t * child;
_LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_coord_t obj_w = lv_obj_get_width(child);
if(act_x + obj_w > w_fit + left) {
act_x = left;
act_y += y_ofs;
}
lv_obj_set_pos(child, act_x, act_y);
act_x += inner + obj_w;
}
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}
/**
* Handle auto fit. Set the size of the object to involve all children.
* @param cont pointer to an object which size will be modified
*/
static void lv_cont_refr_autofit(lv_obj_t * cont)
{
if(lv_obj_is_protected(cont, LV_PROTECT_CHILD_CHG)) return;
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE && ext->fit_top == LV_FIT_NONE &&
ext->fit_bottom == LV_FIT_NONE) {
return;
}
lv_area_t tight_area;
lv_area_t ori;
lv_obj_t * child_i;
lv_obj_t * par = lv_obj_get_parent(cont);
lv_area_t parent_area;
lv_area_copy(&parent_area, &par->coords);
parent_area.x1 += lv_obj_get_style_pad_left(par, LV_OBJ_PART_MAIN);
parent_area.x2 -= lv_obj_get_style_pad_right(par, LV_OBJ_PART_MAIN);
parent_area.y1 += lv_obj_get_style_pad_top(par, LV_OBJ_PART_MAIN);
parent_area.y2 -= lv_obj_get_style_pad_bottom(par, LV_OBJ_PART_MAIN);
/*Search the side coordinates of the children*/
lv_obj_get_coords(cont, &ori);
lv_obj_get_coords(cont, &tight_area);
bool has_children = _lv_ll_is_empty(&cont->child_ll) ? false : true;
if(has_children) {
tight_area.x1 = LV_COORD_MAX;
tight_area.y1 = LV_COORD_MAX;
tight_area.x2 = LV_COORD_MIN;
tight_area.y2 = LV_COORD_MIN;
_LV_LL_READ(cont->child_ll, child_i) {
if(lv_obj_get_hidden(child_i) != false) continue;
if(ext->fit_left != LV_FIT_PARENT) {
lv_style_int_t mleft = lv_obj_get_style_margin_left(child_i, LV_OBJ_PART_MAIN);
tight_area.x1 = LV_MATH_MIN(tight_area.x1, child_i->coords.x1 - mleft);
}
if(ext->fit_right != LV_FIT_PARENT) {
lv_style_int_t mright = lv_obj_get_style_margin_right(child_i, LV_OBJ_PART_MAIN);
tight_area.x2 = LV_MATH_MAX(tight_area.x2, child_i->coords.x2 + mright);
}
if(ext->fit_top != LV_FIT_PARENT) {
lv_style_int_t mtop = lv_obj_get_style_margin_top(child_i, LV_OBJ_PART_MAIN);
tight_area.y1 = LV_MATH_MIN(tight_area.y1, child_i->coords.y1 - mtop);
}
if(ext->fit_bottom != LV_FIT_PARENT) {
lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(child_i, LV_OBJ_PART_MAIN);
tight_area.y2 = LV_MATH_MAX(tight_area.y2, child_i->coords.y2 + mbottom);
}
}
tight_area.x1 -= lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);
tight_area.x2 += lv_obj_get_style_pad_right(cont, LV_CONT_PART_MAIN);
tight_area.y1 -= lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
tight_area.y2 += lv_obj_get_style_pad_bottom(cont, LV_CONT_PART_MAIN);
}
lv_area_t new_area;
lv_area_copy(&new_area, &ori);
switch(ext->fit_left) {
case LV_FIT_TIGHT:
new_area.x1 = tight_area.x1;
break;
case LV_FIT_PARENT:
new_area.x1 = parent_area.x1;
break;
case LV_FIT_MAX:
new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, parent_area.x1) : parent_area.x1;
break;
default:
break;
}
switch(ext->fit_right) {
case LV_FIT_TIGHT:
new_area.x2 = tight_area.x2;
break;
case LV_FIT_PARENT:
new_area.x2 = parent_area.x2;
break;
case LV_FIT_MAX:
new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, parent_area.x2) : parent_area.x2;
break;
default:
break;
}
switch(ext->fit_top) {
case LV_FIT_TIGHT:
new_area.y1 = tight_area.y1;
break;
case LV_FIT_PARENT:
new_area.y1 = parent_area.y1;
break;
case LV_FIT_MAX:
new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, parent_area.y1) : parent_area.y1;
break;
default:
break;
}
switch(ext->fit_bottom) {
case LV_FIT_TIGHT:
new_area.y2 = tight_area.y2;
break;
case LV_FIT_PARENT:
new_area.y2 = parent_area.y2;
break;
case LV_FIT_MAX:
new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, parent_area.y2) : parent_area.y2;
break;
default:
break;
}
/*Do nothing if the coordinates are not changed*/
if(cont->coords.x1 != new_area.x1 || cont->coords.y1 != new_area.y1 || cont->coords.x2 != new_area.x2 ||
cont->coords.y2 != new_area.y2) {
lv_obj_invalidate(cont);
lv_area_copy(&cont->coords, &new_area);
lv_obj_invalidate(cont);
/*Notify the object about its new coordinates*/
cont->signal_cb(cont, LV_SIGNAL_COORD_CHG, &ori);
/*Inform the parent about the new coordinates*/
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, cont);
if(lv_obj_get_auto_realign(cont)) {
lv_obj_realign(cont);
}
/*Tell the children the parent's size has changed*/
_LV_LL_READ(cont->child_ll, child_i) {
child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, &ori);
}
}
}
#endif

View File

@ -52,7 +52,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 list_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);
@ -1128,7 +1128,7 @@ static lv_res_t list_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;
}
@ -1156,36 +1156,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

@ -652,10 +652,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

@ -470,6 +470,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

@ -183,10 +183,10 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const
_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;
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*/
strcpy(ext->cell_data[cell] + 1, txt); /*+1 to skip the format byte*/
#endif
ext->cell_data[cell][0] = format.format_byte;
@ -241,12 +241,12 @@ void lv_table_set_cell_value_fmt(lv_obj_t * table, uint16_t row, uint16_t col, c
}
va_list ap, ap2;
va_start(ap, fmt);
va_copy(ap2, ap);
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);
/*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*/
@ -819,6 +819,8 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
cell_area.y2 = table->coords.y1 + bg_top - 1 - lv_obj_get_scroll_top(table);
lv_coord_t scroll_left = lv_obj_get_scroll_left(table);
bool rtl = lv_obj_get_base_dir(table) == LV_BIDI_DIR_RTL ? true : false;
for(row = 0; row < ext->row_cnt; row++) {
lv_coord_t h_row = ext->row_h[row];
@ -827,7 +829,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 - scroll_left;
if(rtl) cell_area.x1 = table->coords.x2 - bg_right - 1 - scroll_left;
else cell_area.x2 = table->coords.x1 + bg_left - 1 - scroll_left;
for(col = 0; col < ext->col_cnt; col++) {
@ -842,15 +845,22 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
format.s.crop = 1;
}
cell_area.x1 = cell_area.x2 + 1;
cell_area.x2 = cell_area.x1 + ext->col_w[col] - 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;
}
@ -1042,10 +1052,11 @@ static lv_style_list_t * lv_table_get_style(lv_obj_t * table, uint8_t part)
/* 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];
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 NULL;

View File

@ -32,12 +32,12 @@ extern "C" {
#define LV_TABLE_COL_MAX 12
#endif
/*
Maximum allowable value of LV_TABLE_CELL_STYLE_CNT is 16
/*
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
#ifndef LV_TABLE_CELL_STYLE_CNT
# define LV_TABLE_CELL_STYLE_CNT 4
#endif
#if (LV_TABLE_CELL_STYLE_CNT > 16)

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