diff --git a/.github/workflows/build_micropython.yml b/.github/workflows/build_micropython.yml index b7097d5b3..2608abde4 100644 --- a/.github/workflows/build_micropython.yml +++ b/.github/workflows/build_micropython.yml @@ -21,11 +21,13 @@ jobs: run: git clone https://github.com/lvgl/lv_micropython.git . - name: Update submodules run: git submodule update --init --recursive - - name: Checkout lv_bindings + - name: Checkout LVGL submodule working-directory: ./lib/lv_bindings/lvgl run: | - git fetch - git checkout $GITHUB_SHA + git fetch --force ${{ github.event.repository.git_url }} "+refs/heads/*:refs/remotes/origin/*" + git fetch --force ${{ github.event.repository.git_url }} "+refs/pull/*:refs/remotes/origin/pr/*" + git checkout ${{ github.sha }} || git checkout ${{ github.event.pull_request.head.sha }} + git submodule update --init --recursive - name: Build mpy-cross run: make -j $(nproc) -C mpy-cross - name: Build the unix port diff --git a/CHANGELOG.md b/CHANGELOG.md index 69d1f8623..602710fe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,35 @@ # Changelog -## v7.6.0 (TBD) +## v7.7.0 (22.09.2020) ### New features -- Check wheter the any style property has changed on a state change to decide if any redraw is required -## v7.5.0 (planned at 15.09.2020) +### Bugfixes + +## v7.6.0 (22.09.2020) + +### New features +- Check whether any style property has changed on a state change to decide if any redraw is required + +### Bugfixes +- Fix selection of options with non-ASCII letters in dropdown list +- Fix font loader to support LV_FONT_FMT_TXT_LARGE + +## v7.5.0 (15.09.2020) ### New features - Add `clean_dcache_cb` and `lv_disp_clean_dcache` to enable users to use their own cache management function - Add `gpu_wait_cb` to wait until the GPU is working. It allows to run CPU a wait only when the rendered data is needed. +- Add 10px and 8ox built in fonts ### Bugfixes - Fix unexpeted DEFOCUS on lv_page when clicking to bg after the scrollable - Fix `lv_obj_del` and `lv_obj_clean` if the children list changed during deletion. - Adjust button matrix button width to include padding when spanning multiple units. +- Add rounding to btnmatrix line height calculation +- Add `decmopr_buf` to GC roots +- Fix divisioin by zero in draw_pattern (lv_draw_rect.c) if the image or letter is not found +- Fix drawing images with 1 px height or width ## v7.4.0 (01.09.2020) @@ -26,7 +41,7 @@ The main new features of v7.4 are run-time font loading, style caching and arc k - Add style caching to reduce acces time of properties with default value - arc: add set value by click feature - arc: add `LV_ARC_PART_KNOB` similarly to slider -- send gestures even is the the obejct was dragged. User can check dragging with `lv_indev_is_dragging(lv_indev_act())` in the event function. +- send gestures even if the the obejct was dragged. User can check dragging with `lv_indev_is_dragging(lv_indev_act())` in the event function. ### Bugfixes - Fix color bleeding on border drawing diff --git a/a.patch b/a.patch deleted file mode 100644 index 9616d7c22..000000000 --- a/a.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/scripts/release.py b/scripts/release.py -index 28370c66..bc5234e7 100755 ---- a/scripts/release.py -+++ b/scripts/release.py -@@ -395,12 +395,12 @@ def docs_update_dev_version(): - os.chdir("../") - - --def publish_dev(): -+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) - -- pub_cmd = "git checkout dev; git push origin dev" -- cmd("cd docs; " + pub_cmd) - cmd("cd docs; git checkout master; ./update.py latest dev") - - def cleanup(): -@@ -463,7 +463,7 @@ if __name__ == '__main__': - - lvgl_update_dev_version() - docs_update_dev_version() -- publish_dev() -+ publish_dev_and_master() - - cleanup() - diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 1c4cdac93..eb63f9fe0 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -28,9 +28,10 @@ Planned to September/October 2020 - Add radio button widget ## v9 -- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3).7 +- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3). - Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658) - Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660) +- Consider direct binary font format support ## Ideas - CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736) diff --git a/examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino b/examples/LVGL_Arduino.ino similarity index 100% rename from examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino rename to examples/LVGL_Arduino.ino diff --git a/examples/arduino/ESP32_TFT_eSPI/README.md b/examples/arduino/ESP32_TFT_eSPI/README.md deleted file mode 100644 index 10f583d42..000000000 --- a/examples/arduino/ESP32_TFT_eSPI/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Example for lv_arduino using a slider - -This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file: - -```C -int screenWidth = 480; -int screenHeight = 320; -``` - -## Backlight - -Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve: - -```C - ledcSetup(10, 5000/*freq*/, 10 /*resolution*/); - ledcAttachPin(32, 10); - analogReadResolution(10); - ledcWrite(10,768); -``` - -## Theme selection - -Change the following to change the theme: - -```C - lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme - lv_theme_set_current(th); -``` - -## Calibration - -This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values: - -```C -uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; -``` - -## Screen rotation - -Check the following if you need to alter your screen rotation: - -```C - tft.setRotation(3); -``` diff --git a/examples/arduino/README.md b/examples/arduino/README.md deleted file mode 100644 index c5938a664..000000000 --- a/examples/arduino/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# LVGL Arduino examples - -LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library. -It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL. - -## Example - -There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing. -To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder. - -LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it: -1. Go to directory of the installed Arduno libraries -2. Go to `lvgl` and copy `lv_conf_template.h` as `lv_conf.h` next to the `src` folder. -3. Open `lv_conf.h` and change the first `#if 0` to `#if 1` -4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX` -5. Set the color depth of you display in `LV_COLOR_DEPTH` -6. Set `LV_TICK_CUSTOM 1` - -## Debugging - -In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`: - -```c -/*Log settings*/ -#define USE_LV_LOG 1 /*Enable/disable the log module*/ -#if LV_USE_LOG -/* How important log should be added: - * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO Log important events - * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem - * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail - * LV_LOG_LEVEL_NONE Do not log anything - */ -# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN -``` - -After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd. diff --git a/library.json b/library.json index 5f6adb3ed..d324347db 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "7.4.0", + "version": "7.6.0", "keywords": "graphics, gui, embedded, tft, lvgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": { diff --git a/library.properties b/library.properties index 4a160a47f..3fd5bbc96 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=lvgl -version=7.4.0 +version=7.6.0 author=kisvegabor maintainer=kisvegabor,embeddedt,pete-pjb sentence=Full-featured Graphics Library for Embedded Systems diff --git a/lv_conf_template.h b/lv_conf_template.h index 9f295a079..8997a9985 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1,6 +1,6 @@ /** * @file lv_conf.h - * Configuration file for v7.6.0-dev + * Configuration file for v7.7.0-dev */ /* @@ -361,6 +361,8 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i /* Montserrat fonts with bpp = 4 * https://fonts.google.com/specimen/Montserrat */ +#define LV_FONT_MONTSERRAT_8 0 +#define LV_FONT_MONTSERRAT_10 0 #define LV_FONT_MONTSERRAT_12 0 #define LV_FONT_MONTSERRAT_14 1 #define LV_FONT_MONTSERRAT_16 0 @@ -645,6 +647,7 @@ typedef void * lv_obj_user_data_t; #define LV_USE_TABLE 1 #if LV_USE_TABLE # define LV_TABLE_COL_MAX 12 +# define LV_TABLE_CELL_STYLE_CNT 4 #endif /*================== diff --git a/lvgl.h b/lvgl.h index c6521df22..102ab1caa 100644 --- a/lvgl.h +++ b/lvgl.h @@ -15,7 +15,7 @@ extern "C" { * CURRENT VERSION OF LVGL ***************************/ #define LVGL_VERSION_MAJOR 7 -#define LVGL_VERSION_MINOR 6 +#define LVGL_VERSION_MINOR 7 #define LVGL_VERSION_PATCH 0 #define LVGL_VERSION_INFO "dev" diff --git a/r.patch b/r.patch deleted file mode 100644 index e3f80d539..000000000 --- a/r.patch +++ /dev/null @@ -1,62 +0,0 @@ -diff --git a/scripts/release.py b/scripts/release.py -index c06bf529..3a7f27b8 100755 ---- a/scripts/release.py -+++ b/scripts/release.py -@@ -59,6 +59,9 @@ 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 = "" -@@ -309,7 +312,7 @@ 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 theirs") -+ cmd("git merge master -X ours") # Use ours to keep the version numbers - cmd("git add .") - cmd("git commit -am 'Merge master'", False) - cmd("git push origin dev") -@@ -473,6 +476,11 @@ if __name__ == '__main__': - exit(1) - - clone_repos() -+ get_lvgl_version("dev") -+ dev_ver_major = ver_major -+ dev_ver_minor = ver_minor -+ dev_ver_patch = ver_patch -+ - get_lvgl_version("master") - lvgl_prepare() - lv_examples_prepare() -@@ -483,16 +491,17 @@ if __name__ == '__main__': - 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" -+ ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch) + "-dev" - - print("Prepare bugfix version " + ver_str) - - lvgl_update_master_version() - docs_update_latest_version() - -- get_lvgl_version("dev") - dev_ver_str = "v" + ver_major + "." + ver_minor + "." + ver_patch + "-dev" - merge_to_dev() - -@@ -520,6 +529,5 @@ if __name__ == '__main__': - docs_update_dev_version() - publish_dev_and_master() - -- projs_update() - cleanup() - diff --git a/scripts/built_in_font/generate_all.py b/scripts/built_in_font/generate_all.py index 2242fde94..348b95120 100755 --- a/scripts/built_in_font/generate_all.py +++ b/scripts/built_in_font/generate_all.py @@ -2,13 +2,15 @@ import os -print("\nGenerating 16 px CJK") -os.system(u"./built_in_font_gen.py --size 16 -o lv_font_simsun_16_cjk.c --bpp 4 --font SimSun.woff -r 0x20-0x7f --symbols 一在有個我不這了他也就人都說而我們你了要會對及和與以很種的大能著她那上但年還可以最自己為來所他們兩各可為或好等又將因為於由從更被才已者每次把三什麼問題其讓此做再所以只與則台灣卻並位想去呢學生表示到公司將如果社會看小天因此新但是它中使工作全覺得使用這些裡並由於時候知道這樣一認為時間事過向可能中國美國到和幾系統政府大家國家許多生活跟已經大學研究因本二活動該世界應四希望方式內項啊下環境一些必須文化高孩子沒有不能如開始元不同仍網路日本用中心來對雖然重要地方進行關係市場太老師提供學校應該指出經濟其他家發展教育成為多非常便方面很多吃然後未發現電腦一樣而且心不過無法企業正服務較不會臺灣曾嗎空間看到五如何國內們無對於以及之後可是當人員比先產品資訊資料比較先生地除了大陸需要像在給歲請月些名另若亦地區技術至特別其實國際不要發生參加一定其中問台北包括講造成看像常即喜歡去沒出現政治話走單位一直吧是否當然整處理歷史了解那怎麼機會家聽所有只要朋友令甚至用真六呀情況還是錢方法點任何經驗藝術你們十主要媽媽增加提出為什麼以您計畫作利用東西在條設計找之間成長能夠決定學習誰見半時代完成帶相當同學件能力別人生命下來場會議容易開發民眾事情書事實有關自組織言多愛建立相關均產生多業者解決完全的話接受知約一般推動過程管理功能手打水要求小朋友教授難我國告訴內容結果調查家庭成立選擇經營然而父母寫人類至於買尤其配合進入例如得討論依作品情形資源原因啦妳運動觀念給軟體品質經過如此嗯精神影響之過好像成參與以後於是部分另外公園透過訓練努力研究具有共同所謂下行為合作經合作目標起來考慮長意見辦法音樂連受廠商隻受到一切或是中央某女性教學極獲得真的路來快國小部份工程女人舉行句只是段根據現象人民土地面對注意這裡新聞繼續相信政策變成計劃強調學人士前前存在制度意義代表課程該沒至需求人生那些成功爸爸產業負責民間雖影響直接幾乎分實際團體價值使得類形成科技這麼當七不但往本身標準似乎應用或者動物電話態度建設事業老那麼常常字坐舉辦自我有的具目的塊條件即使好十分多少放又電影科學執行邊委員會溝通開一起張針對員工引起自然那麼安全總統此外擁有並且事件設計研究所語言嚴重故事學術片設備之外車基本實在久套達到改善死結構住皆改變拿小組支持座醫院既僅值得學者八交通階段就是申請主管申請同感覺電視母親嘛香港記者壓力快樂喝敢院也許人們談生產怕就身體規定程度積極知識作為機構而是鼓勵角色狀況專家據清楚不僅比賽玩效果越保護共開放附近上父親專業經費曾經工作願意分別重視不少歡迎小孩小時中國人顯示中共出男人避免屬於實施聲音主義行動不可只有校園興趣山表現得回來主任裡面經常不再電子受思想頭終於謝謝協助除當地正式真正低性份因素推出上價格去認識方向責任說明工業大量做逐漸心理一點供須簡單運用觀察往往規劃減少重新業務報導仍然感到開放領域有效女要從事發揮人才反而行政銀行公共媒體提高代自然社區力量啊教育部愈超過維持家長結合校長通常缺乏委員特色結果有時教師之前遠控制本否則法少原則要臉通過建議工具作業達節目智慧來自而變化同樣形式站以為健康擔任人口規劃剛特殊原來道分傳統總是前往投資加強不斷對象追求加上比思考製作台北市取得出來加入台安排兒童國中範圍老人雙方牠北京年輕結束教程式婦女找到彼此全球成本回到部而已之下等變期間非小姐整體採用根本叫歐洲正在加以充滿系列隨著早等等頗不足總分析深報告不錯在於旁笑故消費者意識公尺民族為主大眾到底願度大概對方官員發表進一步自由正確豐富國民黨戰爭怎麼樣只好明顯改革表達肯定強高興哪樹適合茶別國外關心蘇聯成績人物聽到創造不必不論尚居民不管美麗伊拉克帶來有般永遠感情兒子這樣子起全部".encode('utf-8')) -os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_simsun_16_cjk.c') +print("Generating 8 px") +os.system("./built_in_font_gen.py --size 8 -o lv_font_montserrat_8.c --bpp 4") +os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_8.c') -exit() +print("\nGenerating 10 px") +os.system("./built_in_font_gen.py --size 10 -o lv_font_montserrat_10.c --bpp 4") +os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_10.c') -print("Generating 12 px") +print("\nGenerating 12 px") os.system("./built_in_font_gen.py --size 12 -o lv_font_montserrat_12.c --bpp 4") os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_12.c') @@ -96,7 +98,7 @@ print("\nGenerating 16 px CJK") os.system(u"./built_in_font_gen.py --size 16 -o lv_font_simsun_16_cjk.c --bpp 4 --font SimSun.woff -r 0x20-0x7f --symbols 一在有個我不這了他也就人都說而我們你了要會對及和與以很種的大能著她那上但年還可以最自己為來所他們兩各可為或好等又將因為於由從更被才已者每次把三什麼問題其讓此做再所以只與則台灣卻並位想去呢學生表示到公司將如果社會看小天因此新但是它中使工作全覺得使用這些裡並由於時候知道這樣一認為時間事過向可能中國美國到和幾系統政府大家國家許多生活跟已經大學研究因本二活動該世界應四希望方式內項啊下環境一些必須文化高孩子沒有不能如開始元不同仍網路日本用中心來對雖然重要地方進行關係市場太老師提供學校應該指出經濟其他家發展教育成為多非常便方面很多吃然後未發現電腦一樣而且心不過無法企業正服務較不會臺灣曾嗎空間看到五如何國內們無對於以及之後可是當人員比先產品資訊資料比較先生地除了大陸需要像在給歲請月些名另若亦地區技術至特別其實國際不要發生參加一定其中問台北包括講造成看像常即喜歡去沒出現政治話走單位一直吧是否當然整處理歷史了解那怎麼機會家聽所有只要朋友令甚至用真六呀情況還是錢方法點任何經驗藝術你們十主要媽媽增加提出為什麼以您計畫作利用東西在條設計找之間成長能夠決定學習誰見半時代完成帶相當同學件能力別人生命下來場會議容易開發民眾事情書事實有關自組織言多愛建立相關均產生多業者解決完全的話接受知約一般推動過程管理功能手打水要求小朋友教授難我國告訴內容結果調查家庭成立選擇經營然而父母寫人類至於買尤其配合進入例如得討論依作品情形資源原因啦妳運動觀念給軟體品質經過如此嗯精神影響之過好像成參與以後於是部分另外公園透過訓練努力研究具有共同所謂下行為合作經合作目標起來考慮長意見辦法音樂連受廠商隻受到一切或是中央某女性教學極獲得真的路來快國小部份工程女人舉行句只是段根據現象人民土地面對注意這裡新聞繼續相信政策變成計劃強調學人士前前存在制度意義代表課程該沒至需求人生那些成功爸爸產業負責民間雖影響直接幾乎分實際團體價值使得類形成科技這麼當七不但往本身標準似乎應用或者動物電話態度建設事業老那麼常常字坐舉辦自我有的具目的塊條件即使好十分多少放又電影科學執行邊委員會溝通開一起張針對員工引起自然那麼安全總統此外擁有並且事件設計研究所語言嚴重故事學術片設備之外車基本實在久套達到改善死結構住皆改變拿小組支持座醫院既僅值得學者八交通階段就是申請主管申請同感覺電視母親嘛香港記者壓力快樂喝敢院也許人們談生產怕就身體規定程度積極知識作為機構而是鼓勵角色狀況專家據清楚不僅比賽玩效果越保護共開放附近上父親專業經費曾經工作願意分別重視不少歡迎小孩小時中國人顯示中共出男人避免屬於實施聲音主義行動不可只有校園興趣山表現得回來主任裡面經常不再電子受思想頭終於謝謝協助除當地正式真正低性份因素推出上價格去認識方向責任說明工業大量做逐漸心理一點供須簡單運用觀察往往規劃減少重新業務報導仍然感到開放領域有效女要從事發揮人才反而行政銀行公共媒體提高代自然社區力量啊教育部愈超過維持家長結合校長通常缺乏委員特色結果有時教師之前遠控制本否則法少原則要臉通過建議工具作業達節目智慧來自而變化同樣形式站以為健康擔任人口規劃剛特殊原來道分傳統總是前往投資加強不斷對象追求加上比思考製作台北市取得出來加入台安排兒童國中範圍老人雙方牠北京年輕結束教程式婦女找到彼此全球成本回到部而已之下等變期間非小姐整體採用根本叫歐洲正在加以充滿系列隨著早等等頗不足總分析深報告不錯在於旁笑故消費者意識公尺民族為主大眾到底願度大概對方官員發表進一步自由正確豐富國民黨戰爭怎麼樣只好明顯改革表達肯定強高興哪樹適合茶別國外關心蘇聯成績人物聽到創造不必不論尚居民不管美麗伊拉克帶來有般永遠感情兒子這樣子起全部".encode('utf-8')) os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_simsun_16_cjk.c') -print("Generating 16 px Hebrew, Persian") +print("\nGenerating 16 px Hebrew, Persian") os.system("./built_in_font_gen.py --size 16 -o lv_font_dejavu_16_persian_hebrew.c --bpp 4 --font DejaVuSans.ttf -r 0x20-0x7f,0x5d0-0x5ea,0x600-0x6FF,0xFB50-0xFDFF,0xFE70-0xFEFF") os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_dejavu_16_persian_hebrew.c') diff --git a/scripts/release.py b/scripts/release.py index c06bf5292..b5002b901 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -60,6 +60,10 @@ 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 = "" @@ -103,19 +107,19 @@ 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") - cmd("git clone " + upstream("lv_examples") + "; cd lv_examples; git checkout master") - cmd("git clone " + upstream("lv_drivers") + "; cd lv_drivers; git checkout master") - cmd("git clone --recurse-submodules " + upstream("docs") + "; cd docs; git checkout master") - cmd("git clone " + upstream("blog") + "; cd blog; git checkout master") + 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") + cmd("git clone " + upstream(p) + " --recurse-submodules ; cd " + p + "; git checkout master; git remote update origin --prune; ") def get_lvgl_version(br): @@ -309,7 +313,7 @@ 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 theirs") + cmd("git merge master -X ours") cmd("git add .") cmd("git commit -am 'Merge master'", False) cmd("git push origin dev") @@ -320,28 +324,15 @@ def publish_master(): cmd("cd lvgl; " + pub_cmd) cmd("cd lv_examples; " + pub_cmd) cmd("cd lv_drivers; " + pub_cmd) - - pub_cmd = "git push origin latest; git push origin " + ver_str - cmd("cd docs; " + pub_cmd) - cmd("cd docs; git checkout master; python 2.7 ./update.py " + release_br) pub_cmd = "git push origin master" - cmd("cd blog; " + pub_cmd) - - -def merge_to_dev(): - merge_cmd = "git checkout dev; git pull origin dev; git merge master -X ours; git checkout master" - cmd("cd lvgl; " + merge_cmd) - - merge_cmd = "git checkout dev --; git pull origin dev; git merge latest -X ours; git checkout master" - cmd("cd docs; " + merge_cmd) - + 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;" + merge_cmd = "git checkout latest -- ; git merge dev -X theirs --no-edit;" cmd("cd docs; " + merge_cmd) @@ -418,8 +409,6 @@ def publish_dev_and_master(): pub_cmd = "git checkout master; git push origin master" cmd("cd lvgl; " + pub_cmd) - cmd("cd docs; git checkout master; python 2.7 ./update.py latest dev") - def projs_update(): global proj_list, release_br, ver_str for p in proj_list: @@ -454,14 +443,16 @@ def projs_update(): 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 = 'minor' + dev_prepare = 'bugfix' if(len(sys.argv) != 2): print("Missing argument. Usage ./release.py bugfix | minor | major") print("Use minor by deafult") @@ -473,7 +464,14 @@ if __name__ == '__main__': 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() @@ -482,7 +480,9 @@ if __name__ == '__main__': 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" @@ -492,15 +492,11 @@ if __name__ == '__main__': lvgl_update_master_version() docs_update_latest_version() - get_lvgl_version("dev") - dev_ver_str = "v" + ver_major + "." + ver_minor + "." + ver_patch + "-dev" - merge_to_dev() - - lvgl_update_dev_version() - docs_update_dev_version() - publish_dev() else: - get_lvgl_version("dev") + #merge_from_dev() + + get_lvgl_version("master") + if dev_prepare == 'minor': ver_minor = str(int(ver_minor) + 1) ver_patch = "0" @@ -513,13 +509,10 @@ if __name__ == '__main__': print("Prepare minor version " + dev_ver_str) - merge_to_dev() - merge_from_dev() - lvgl_update_dev_version() docs_update_dev_version() publish_dev_and_master() - projs_update() + docs_update_all(); cleanup() diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 4c4d8e699..6c3fca221 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -818,6 +818,20 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* Montserrat fonts with bpp = 4 * https://fonts.google.com/specimen/Montserrat */ +#ifndef LV_FONT_MONTSERRAT_8 +# ifdef CONFIG_LV_FONT_MONTSERRAT_8 +# define LV_FONT_MONTSERRAT_8 CONFIG_LV_FONT_MONTSERRAT_8 +# else +# define LV_FONT_MONTSERRAT_8 0 +# endif +#endif +#ifndef LV_FONT_MONTSERRAT_10 +# ifdef CONFIG_LV_FONT_MONTSERRAT_10 +# define LV_FONT_MONTSERRAT_10 CONFIG_LV_FONT_MONTSERRAT_10 +# else +# define LV_FONT_MONTSERRAT_10 0 +# endif +#endif #ifndef LV_FONT_MONTSERRAT_12 # ifdef CONFIG_LV_FONT_MONTSERRAT_12 # define LV_FONT_MONTSERRAT_12 CONFIG_LV_FONT_MONTSERRAT_12 diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index 3f10a9053..89ff8b6e5 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -360,12 +360,12 @@ void lv_disp_clean_dcache(lv_disp_t * disp) { if(!disp) disp = lv_disp_get_default(); if(!disp) { - LV_LOG_WARN("lv_disp_clean_dcache: no display registered"); - return; + LV_LOG_WARN("lv_disp_clean_dcache: no display registered"); + return; } if(disp->driver.clean_dcache_cb) - disp->driver.clean_dcache_cb(&disp->driver); + disp->driver.clean_dcache_cb(&disp->driver); } /** diff --git a/src/lv_core/lv_group.c b/src/lv_core/lv_group.c index e3dc1ac2e..78d3c8d67 100644 --- a/src/lv_core/lv_group.c +++ b/src/lv_core/lv_group.c @@ -217,7 +217,7 @@ void lv_group_focus_obj(lv_obj_t * obj) if(g->frozen != 0) return; - if(obj == *g->obj_focus) return; + if(g->obj_focus != NULL && obj == *g->obj_focus) return; /*On defocus edit mode must be leaved*/ lv_group_set_editing(g, false); diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 43e87b0f6..d0ad96b52 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -746,7 +746,7 @@ static void lv_refr_vdb_flush(void) /*Flush the rendered content to the display*/ lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - if (disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver); + if(disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver); if(disp->driver.flush_cb) disp->driver.flush_cb(&disp->driver, &vdb->area, vdb->buf_act); diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 5841206b0..7149418fe 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -827,8 +827,9 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_int(class, prop, &value_act); + /* changed class to _class to allow compilation as c++ */ + lv_style_t * _class = lv_style_list_get_style(list, ci); + int16_t weight_act = _lv_style_get_int(_class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { @@ -880,8 +881,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_color(class, prop, &value_act); + lv_style_t * _class = lv_style_list_get_style(list, ci); + int16_t weight_act = _lv_style_get_color(_class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; @@ -930,8 +931,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_opa(class, prop, &value_act); + lv_style_t * _class = lv_style_list_get_style(list, ci); + int16_t weight_act = _lv_style_get_opa(_class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; @@ -980,8 +981,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { - lv_style_t * class = lv_style_list_get_style(list, ci); - int16_t weight_act = _lv_style_get_ptr(class, prop, &value_act); + lv_style_t * _class = lv_style_list_get_style(list, ci); + int16_t weight_act = _lv_style_get_ptr(_class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index f4de48e7e..109246556 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -138,8 +138,8 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_ const lv_area_t * disp_area = &vdb->area; lv_color_t * disp_buf = vdb->buf_act; - if (disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver); - + if(disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver); + /* Get clipped fill area which is the real draw area. * It is always the same or inside `fill_area` */ lv_area_t draw_area; @@ -213,8 +213,8 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a const lv_area_t * disp_area = &vdb->area; lv_color_t * disp_buf = vdb->buf_act; - if (disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver); - + if(disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver); + /* Now `draw_area` has absolute coordinates. * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ draw_area.x1 -= disp_area->x1; diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 113393e34..a21059edc 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -220,7 +220,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area if((dsc->decor & LV_TEXT_DECOR_UNDERLINE) || (dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH)) { lv_draw_line_dsc_init(&line_dsc); line_dsc.color = dsc->color; - line_dsc.width = font->underline_thickness ? font->underline_thickness : LV_MATH_MAX(font->line_height / 10, 1); + line_dsc.width = font->underline_thickness ? font->underline_thickness : 1; line_dsc.opa = dsc->opa; line_dsc.blend_mode = dsc->blend_mode; } diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 08682b789..b2d517757 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -1229,6 +1229,9 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const return; } + /*Can't draw zero sized images*/ + if(img_w == 0 || img_h == 0) return; + lv_area_t coords_tmp; if(dsc->pattern_repeat) { diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index 644a55e42..d9a1aed95 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -131,6 +131,14 @@ static inline lv_coord_t lv_font_get_line_height(const lv_font_t * font_p) #define LV_FONT_DECLARE(font_name) extern lv_font_t font_name; +#if LV_FONT_MONTSERRAT_8 +LV_FONT_DECLARE(lv_font_montserrat_8) +#endif + +#if LV_FONT_MONTSERRAT_10 +LV_FONT_DECLARE(lv_font_montserrat_10) +#endif + #if LV_FONT_MONTSERRAT_12 LV_FONT_DECLARE(lv_font_montserrat_12) #endif diff --git a/src/lv_font/lv_font_dejavu_16_persian_hebrew.c b/src/lv_font/lv_font_dejavu_16_persian_hebrew.c index 357de25d5..8a32111a7 100644 --- a/src/lv_font/lv_font_dejavu_16_persian_hebrew.c +++ b/src/lv_font/lv_font_dejavu_16_persian_hebrew.c @@ -6540,6 +6540,10 @@ lv_font_t lv_font_dejavu_16_persian_hebrew = { .base_line = 7, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index 7ac5e1e42..bc9a49a75 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -11,10 +11,15 @@ #include "../lv_misc/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_misc/lv_types.h" +#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_log.h" #include "../lv_misc/lv_utils.h" #include "../lv_misc/lv_mem.h" +#if defined(LV_GC_INCLUDE) + #include LV_GC_INCLUDE +#endif /* LV_ENABLE_GC */ + /********************* * DEFINES *********************/ @@ -47,7 +52,6 @@ static inline uint8_t rle_next(void); /********************** * STATIC VARIABLES **********************/ -static uint8_t * decompr_buf; static uint32_t rle_rdp; static const uint8_t * rle_in; static uint8_t rle_bpp; @@ -109,16 +113,17 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic break; } - if(_lv_mem_get_size(decompr_buf) < buf_size) { - decompr_buf = lv_mem_realloc(decompr_buf, buf_size); - LV_ASSERT_MEM(decompr_buf); - if(decompr_buf == NULL) return NULL; + if(_lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) { + LV_GC_ROOT(_lv_font_decompr_buf) = lv_mem_realloc(LV_GC_ROOT(_lv_font_decompr_buf), buf_size); + LV_ASSERT_MEM(LV_GC_ROOT(_lv_font_decompr_buf)); + if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) return NULL; } bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false; - decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, + decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], LV_GC_ROOT(_lv_font_decompr_buf), gdsc->box_w, gdsc->box_h, + (uint8_t)fdsc->bpp, prefilter); - return decompr_buf; + return LV_GC_ROOT(_lv_font_decompr_buf); #else /* !LV_USE_FONT_COMPRESSED */ return NULL; #endif @@ -184,9 +189,9 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * */ void _lv_font_clean_up_fmt_txt(void) { - if(decompr_buf) { - lv_mem_free(decompr_buf); - decompr_buf = NULL; + if(LV_GC_ROOT(_lv_font_decompr_buf)) { + lv_mem_free(LV_GC_ROOT(_lv_font_decompr_buf)); + LV_GC_ROOT(_lv_font_decompr_buf) = NULL; } } diff --git a/src/lv_font/lv_font_loader.c b/src/lv_font/lv_font_loader.c index cb9e78a21..ba89955a6 100644 --- a/src/lv_font/lv_font_loader.c +++ b/src/lv_font/lv_font_loader.c @@ -225,7 +225,7 @@ static int read_bits_signed(bit_iterator_t * it, int n_bits, lv_fs_res_t * res) { int value = read_bits(it, n_bits, res); if(value & (1 << (n_bits - 1))) { - for(int bit = n_bits; bit < 8; ++bit) { + for(int bit = n_bits; bit < 16; ++bit) { value |= (1 << bit); } } diff --git a/src/lv_font/lv_font_montserrat_12.c b/src/lv_font/lv_font_montserrat_12.c index dc4a2ff8c..209eea93e 100644 --- a/src/lv_font/lv_font_montserrat_12.c +++ b/src/lv_font/lv_font_montserrat_12.c @@ -1867,6 +1867,10 @@ lv_font_t lv_font_montserrat_12 = { .base_line = 3, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_12_subpx.c b/src/lv_font/lv_font_montserrat_12_subpx.c index cda4c41ab..2bd1fc68d 100644 --- a/src/lv_font/lv_font_montserrat_12_subpx.c +++ b/src/lv_font/lv_font_montserrat_12_subpx.c @@ -1867,6 +1867,10 @@ lv_font_t lv_font_montserrat_12_subpx = { .base_line = 3, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_14.c b/src/lv_font/lv_font_montserrat_14.c index 09d7c12b5..978742d5e 100644 --- a/src/lv_font/lv_font_montserrat_14.c +++ b/src/lv_font/lv_font_montserrat_14.c @@ -2136,6 +2136,10 @@ lv_font_t lv_font_montserrat_14 = { .base_line = 3, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_16.c b/src/lv_font/lv_font_montserrat_16.c index 9824db94e..eeaed4f80 100644 --- a/src/lv_font/lv_font_montserrat_16.c +++ b/src/lv_font/lv_font_montserrat_16.c @@ -2399,6 +2399,10 @@ lv_font_t lv_font_montserrat_16 = { .base_line = 3, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_18.c b/src/lv_font/lv_font_montserrat_18.c index 181c23cd8..c1850de0f 100644 --- a/src/lv_font/lv_font_montserrat_18.c +++ b/src/lv_font/lv_font_montserrat_18.c @@ -2788,6 +2788,10 @@ lv_font_t lv_font_montserrat_18 = { .base_line = 4, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_20.c b/src/lv_font/lv_font_montserrat_20.c index 6d9a5e66f..6403288da 100644 --- a/src/lv_font/lv_font_montserrat_20.c +++ b/src/lv_font/lv_font_montserrat_20.c @@ -3134,6 +3134,10 @@ lv_font_t lv_font_montserrat_20 = { .base_line = 4, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_22.c b/src/lv_font/lv_font_montserrat_22.c index 1a88d2891..e1c1e42af 100644 --- a/src/lv_font/lv_font_montserrat_22.c +++ b/src/lv_font/lv_font_montserrat_22.c @@ -3551,6 +3551,10 @@ lv_font_t lv_font_montserrat_22 = { .base_line = 4, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_24.c b/src/lv_font/lv_font_montserrat_24.c index b38f24a28..22f5f3a7e 100644 --- a/src/lv_font/lv_font_montserrat_24.c +++ b/src/lv_font/lv_font_montserrat_24.c @@ -3952,6 +3952,10 @@ lv_font_t lv_font_montserrat_24 = { .base_line = 5, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_26.c b/src/lv_font/lv_font_montserrat_26.c index 8eff9a16a..6d4e9db0c 100644 --- a/src/lv_font/lv_font_montserrat_26.c +++ b/src/lv_font/lv_font_montserrat_26.c @@ -4472,6 +4472,10 @@ lv_font_t lv_font_montserrat_26 = { .base_line = 5, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_28.c b/src/lv_font/lv_font_montserrat_28.c index 33f1fbf6f..59c381519 100644 --- a/src/lv_font/lv_font_montserrat_28.c +++ b/src/lv_font/lv_font_montserrat_28.c @@ -5006,6 +5006,10 @@ lv_font_t lv_font_montserrat_28 = { .base_line = 5, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_28_compressed.c b/src/lv_font/lv_font_montserrat_28_compressed.c index e6ed44d5d..ef74c0a54 100644 --- a/src/lv_font/lv_font_montserrat_28_compressed.c +++ b/src/lv_font/lv_font_montserrat_28_compressed.c @@ -3196,6 +3196,10 @@ lv_font_t lv_font_montserrat_28_compressed = { .base_line = 5, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_30.c b/src/lv_font/lv_font_montserrat_30.c index 0e9b57768..93e024b01 100644 --- a/src/lv_font/lv_font_montserrat_30.c +++ b/src/lv_font/lv_font_montserrat_30.c @@ -5572,6 +5572,10 @@ lv_font_t lv_font_montserrat_30 = { .base_line = 6, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_32.c b/src/lv_font/lv_font_montserrat_32.c index 196aa0be5..9a4485bec 100644 --- a/src/lv_font/lv_font_montserrat_32.c +++ b/src/lv_font/lv_font_montserrat_32.c @@ -6049,6 +6049,10 @@ lv_font_t lv_font_montserrat_32 = { .base_line = 6, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_34.c b/src/lv_font/lv_font_montserrat_34.c index 3f6bbb164..71f1ee64a 100644 --- a/src/lv_font/lv_font_montserrat_34.c +++ b/src/lv_font/lv_font_montserrat_34.c @@ -6826,6 +6826,10 @@ lv_font_t lv_font_montserrat_34 = { .base_line = 7, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_36.c b/src/lv_font/lv_font_montserrat_36.c index 6947ab7dc..3c4104f2d 100644 --- a/src/lv_font/lv_font_montserrat_36.c +++ b/src/lv_font/lv_font_montserrat_36.c @@ -7453,6 +7453,10 @@ lv_font_t lv_font_montserrat_36 = { .base_line = 7, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_38.c b/src/lv_font/lv_font_montserrat_38.c index 3b92d229a..5f3cb1a8f 100644 --- a/src/lv_font/lv_font_montserrat_38.c +++ b/src/lv_font/lv_font_montserrat_38.c @@ -8176,6 +8176,10 @@ lv_font_t lv_font_montserrat_38 = { .base_line = 7, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_40.c b/src/lv_font/lv_font_montserrat_40.c index 4d691b0f5..a26745b21 100644 --- a/src/lv_font/lv_font_montserrat_40.c +++ b/src/lv_font/lv_font_montserrat_40.c @@ -9008,6 +9008,10 @@ lv_font_t lv_font_montserrat_40 = { .base_line = 8, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_42.c b/src/lv_font/lv_font_montserrat_42.c index f32f489f8..f386e40b1 100644 --- a/src/lv_font/lv_font_montserrat_42.c +++ b/src/lv_font/lv_font_montserrat_42.c @@ -9826,6 +9826,10 @@ lv_font_t lv_font_montserrat_42 = { .base_line = 8, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_44.c b/src/lv_font/lv_font_montserrat_44.c index 6b082bc52..c87339779 100644 --- a/src/lv_font/lv_font_montserrat_44.c +++ b/src/lv_font/lv_font_montserrat_44.c @@ -10626,6 +10626,10 @@ lv_font_t lv_font_montserrat_44 = { .base_line = 9, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_46.c b/src/lv_font/lv_font_montserrat_46.c index 15a297a99..01c1d6877 100644 --- a/src/lv_font/lv_font_montserrat_46.c +++ b/src/lv_font/lv_font_montserrat_46.c @@ -11555,6 +11555,10 @@ lv_font_t lv_font_montserrat_46 = { .base_line = 9, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -3, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_montserrat_48.c b/src/lv_font/lv_font_montserrat_48.c index 8a9dc3503..1d24b1692 100644 --- a/src/lv_font/lv_font_montserrat_48.c +++ b/src/lv_font/lv_font_montserrat_48.c @@ -12237,6 +12237,10 @@ lv_font_t lv_font_montserrat_48 = { .base_line = 9, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -4, + .underline_thickness = 2, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_font/lv_font_simsun_16_cjk.c b/src/lv_font/lv_font_simsun_16_cjk.c index e598253d9..8d57f1e53 100644 --- a/src/lv_font/lv_font_simsun_16_cjk.c +++ b/src/lv_font/lv_font_simsun_16_cjk.c @@ -13591,6 +13591,10 @@ lv_font_t lv_font_simsun_16_cjk = { .base_line = 3, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) + .underline_position = -2, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.c b/src/lv_gpu/lv_gpu_stm32_dma2d.c index f11c4c6a4..4fca9c322 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.c +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.c @@ -219,8 +219,11 @@ static void invalidate_cache(void) { lv_disp_t * disp = _lv_refr_get_disp_refreshing(); if(disp->driver.clean_dcache_cb) disp->driver.clean_dcache_cb(&disp->driver); - else + else { +#if __CORTEX_M >= 0x07 SCB_CleanInvalidateDCache(); +#endif + } } static void dma2d_wait(void) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 8268668e6..3b2014f38 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -596,8 +596,29 @@ static inline uint8_t lv_color_brightness(lv_color_t color) return (uint8_t)(bright >> 3); } -#ifdef __cplusplus -/* Fix of msvc 2019 compiler error C4576 inside C++ code */ +#if defined(__cplusplus) && !defined(_LV_COLOR_HAS_MODERN_CPP) +/** +* 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 +*/ +#ifdef _MSC_VER +#if _MSC_VER >= 1900 /* Visual Studio 2015 */ +#define _LV_COLOR_HAS_MODERN_CPP 1 +#endif +#else +#if __cplusplus >= 201103L +#define _LV_COLOR_HAS_MODERN_CPP 1 +#endif +#endif +#endif /* __cplusplus */ + +#ifndef _LV_COLOR_HAS_MODERN_CPP +#define _LV_COLOR_HAS_MODERN_CPP 0 +#endif + +#if _LV_COLOR_HAS_MODERN_CPP +/* Fix msvc compiler error C4576 inside C++ code */ #define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t #else #define _LV_COLOR_MAKE_TYPE_HELPER (lv_color_t) diff --git a/src/lv_misc/lv_gc.h b/src/lv_misc/lv_gc.h index faecbfa35..c59ca5704 100644 --- a/src/lv_misc/lv_gc.h +++ b/src/lv_misc/lv_gc.h @@ -43,6 +43,8 @@ extern "C" { f(void * , _lv_theme_template_styles) \ f(void * , _lv_theme_mono_styles) \ f(void * , _lv_theme_empty_styles) \ + f(uint8_t *, _lv_font_decompr_buf) \ + #define LV_DEFINE_ROOT(root_type, root_name) root_type root_name; #define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index b5ff691e0..3fbce82bf 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -1266,6 +1266,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_TABLE case LV_THEME_TABLE: +<<<<<<< HEAD list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); @@ -1280,7 +1281,22 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->table_cell); +======= + { + 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 + 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); + } +>>>>>>> dev break; + } #endif #if LV_USE_WIN diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 6ddd50c1d..15e643eea 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -867,6 +867,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_TABLE case LV_THEME_TABLE: +<<<<<<< HEAD list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); @@ -885,7 +886,23 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->no_radius); +======= + { + list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); + _lv_style_list_add_style(list, &styles->bg); + + 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); + } +>>>>>>> dev break; + } #endif #if LV_USE_WIN diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index 606a5f703..fd00ac7e9 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -42,7 +42,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); /********************** * STATIC VARIABLES **********************/ -static lv_theme_t theme; static lv_theme_t theme; static theme_styles_t * styles; @@ -721,21 +720,20 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) #endif #if LV_USE_TABLE case LV_THEME_TABLE: - list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); + { + list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); _lv_style_list_add_style(list, &styles->bg); - list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1); - _lv_style_list_add_style(list, &styles->bg); - - list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2); - _lv_style_list_add_style(list, &styles->bg); - - list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3); - _lv_style_list_add_style(list, &styles->bg); - - list = _lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4); - _lv_style_list_add_style(list, &styles->bg); + int idx = 1; /* start value should be 1, not zero, since cell styles + start at 1 due to presence of LV_TABLE_PART_BG=0 + in the enum (lv_table.h) */ + /* declaring idx outside loop to work with older compilers */ + for (; idx <= LV_TABLE_CELL_STYLE_CNT; idx ++ ) { + list = lv_obj_get_style_list(obj, idx); + _lv_style_list_add_style(list, &styles->bg); + } break; + } #endif #if LV_USE_WIN diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index 92fe9ec6c..67d2dc71e 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -452,7 +452,7 @@ void lv_arc_set_adjustable(lv_obj_t * arc, bool adjustable) { LV_ASSERT_OBJ(arc, LV_OBJX_NAME); - lv_arc_ext_t *ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); + lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); if(ext->adjustable == adjustable) return; @@ -597,7 +597,7 @@ bool lv_arc_get_adjustable(lv_obj_t * arc) { LV_ASSERT_OBJ(arc, LV_OBJX_NAME); - lv_arc_ext_t *ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); + lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); return ext->adjustable; } @@ -1053,10 +1053,10 @@ static void get_knob_area(lv_obj_t * arc, const lv_point_t * center, lv_coord_t */ static void value_update(lv_obj_t * arc) { - lv_arc_ext_t *ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); + lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); int16_t bg_midpoint, range_midpoint, bg_end = ext->bg_angle_end; - if (ext->bg_angle_end < ext->bg_angle_start) bg_end = ext->bg_angle_end + 360; + if(ext->bg_angle_end < ext->bg_angle_start) bg_end = ext->bg_angle_end + 360; int16_t angle; switch(ext->type) { @@ -1064,11 +1064,12 @@ static void value_update(lv_obj_t * arc) bg_midpoint = (ext->bg_angle_start + bg_end) / 2; range_midpoint = (int32_t)(ext->min_value + ext->max_value) / 2; - if (ext->cur_value < range_midpoint) { + if(ext->cur_value < range_midpoint) { angle = _lv_map(ext->cur_value, ext->min_value, range_midpoint, ext->bg_angle_start, bg_midpoint); lv_arc_set_start_angle(arc, angle); lv_arc_set_end_angle(arc, bg_midpoint); - } else { + } + else { angle = _lv_map(ext->cur_value, range_midpoint, ext->max_value, bg_midpoint, bg_end); lv_arc_set_start_angle(arc, bg_midpoint); lv_arc_set_end_angle(arc, angle); diff --git a/src/lv_widgets/lv_arc.h b/src/lv_widgets/lv_arc.h index 53c145c05..9f45184d3 100644 --- a/src/lv_widgets/lv_arc.h +++ b/src/lv_widgets/lv_arc.h @@ -48,9 +48,9 @@ typedef struct { int16_t cur_value; /*Current value of the arc*/ int16_t min_value; /*Minimum value of the arc*/ int16_t max_value; /*Maximum value of the arc*/ - uint16_t dragging :1; - uint16_t type :2; - uint16_t adjustable :1; + uint16_t dragging : 1; + uint16_t type : 2; + uint16_t adjustable : 1; uint16_t chg_rate; /*Drag angle rate of change of the arc (degrees/sec)*/ uint32_t last_tick; /*Last dragging event timestamp of the arc*/ int16_t last_angle; /*Last dragging angle of the arc*/ diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 86cf13b03..d760510ea 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -1358,7 +1358,8 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const LV_COORD_MAX, LV_TXT_FLAG_CENTER); /* set the area at some distance of the major tick len left of the tick */ - lv_area_t a = {.y1 = p2.y - size.y / 2, .y2 = p2.y + size.y / 2}; + /* changed to explicit member initialization to allow compilation as c++ */ + lv_area_t a; a.y1 = p2.y - size.y / 2; a.y2 = p2.y + size.y / 2; if(which_axis == LV_CHART_AXIS_PRIMARY_Y) { a.x1 = p2.x - size.x - label_dist; diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 773b9a911..4555c719e 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -825,9 +825,7 @@ static lv_design_res_t lv_dropdown_page_design(lv_obj_t * page, const lv_area_t draw_box(ddlist, &clip_area_core, ext->pr_opt_id, LV_STATE_PRESSED); } - if(ext->show_selected) { - draw_box(ddlist, &clip_area_core, ext->sel_opt_id, LV_STATE_DEFAULT); - } + draw_box(ddlist, &clip_area_core, ext->sel_opt_id, LV_STATE_DEFAULT); } } } @@ -853,9 +851,7 @@ static lv_design_res_t lv_dropdown_page_design(lv_obj_t * page, const lv_area_t draw_box_label(ddlist, &clip_area_core, ext->pr_opt_id, LV_STATE_PRESSED); } - if(ext->show_selected) { - draw_box_label(ddlist, &clip_area_core, ext->sel_opt_id, LV_STATE_DEFAULT); - } + draw_box_label(ddlist, &clip_area_core, ext->sel_opt_id, LV_STATE_DEFAULT); } } } @@ -1281,10 +1277,12 @@ static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y) y -= label->coords.y1; uint32_t letter_i; + const char * txt = lv_label_get_text(label); + 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; - const char * txt = lv_label_get_text(label); uint32_t i = 0; uint32_t i_prev = 0; @@ -1293,7 +1291,7 @@ static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y) 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) opt++; + if(letter == '\n' && i_prev != letter_i_byte_pos) opt++; i_prev = i; } diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index 97ccd54f3..a555bd5f1 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -207,7 +207,7 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value) lv_coord_t x_ofs = gauge->coords.x1 + r + left + pad; lv_coord_t y_ofs = gauge->coords.y1 + r + top + pad; uint16_t angle = lv_linemeter_get_scale_angle(gauge); - int16_t angle_ofs = 90 + (360 - angle) / 2; + int16_t angle_ofs = 90 + (360 - angle) / 2 + lv_gauge_get_angle_offset(gauge); lv_point_t p_mid; lv_point_t p_end; lv_coord_t needle_w; @@ -240,10 +240,10 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value) p_end.y = (_lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs; p_end.x = (_lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs; - a.x1 = LV_MATH_MIN(p_mid.x, p_end.x); - a.y1 = LV_MATH_MIN(p_mid.y, p_end.y); - a.x2 = LV_MATH_MAX(p_mid.x, p_end.x); - a.y2 = LV_MATH_MAX(p_mid.y, p_end.y); + a.x1 = LV_MATH_MIN(p_mid.x, p_end.x) - needle_w; + a.y1 = LV_MATH_MIN(p_mid.y, p_end.y) - needle_w; + a.x2 = LV_MATH_MAX(p_mid.x, p_end.x) + needle_w; + a.y2 = LV_MATH_MAX(p_mid.y, p_end.y) + needle_w; lv_obj_invalidate_area(gauge, &a); diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 3cea6f477..27a80e54a 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -690,10 +690,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); } } diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 52ae3bc5b..ce1ecabad 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -654,10 +654,14 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ * @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter) * Expressed in character index and not byte index (different in UTF-8) */ -uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) +uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos_in) { LV_ASSERT_OBJ(label, LV_OBJX_NAME); - LV_ASSERT_NULL(pos); + LV_ASSERT_NULL(pos_in); + + lv_point_t pos; + pos.x = pos_in->x - lv_obj_get_style_pad_left(label, LV_LABEL_PART_MAIN); + pos.y = pos_in->y - lv_obj_get_style_pad_top(label, LV_LABEL_PART_MAIN); lv_area_t txt_coords; get_txt_coords(label, &txt_coords); @@ -687,7 +691,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) while(txt[line_start] != '\0') { new_line_start += _lv_txt_get_next_line(&txt[line_start], font, letter_space, max_w, flag); - if(pos->y <= y + letter_height) { + if(pos.y <= y + letter_height) { /*The line is found (stored in 'line_start')*/ /* Include the NULL terminator in the last line */ uint32_t tmp = new_line_start; @@ -746,7 +750,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) lv_coord_t gw = lv_font_get_glyph_width(font, letter, letter_next); /*Finish if the x position or the last char of the next line is reached*/ - if(pos->x < x + (gw >> 1) || i + line_start == new_line_start || txt[i_act + line_start] == '\0') { + if(pos.x < x + gw || i + line_start == new_line_start || txt[i_act + line_start] == '\0') { i = i_act; break; } diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c new file mode 100644 index 000000000..b85610ed0 --- /dev/null +++ b/src/lv_widgets/lv_linemeter.c @@ -0,0 +1,631 @@ +/** + * @file lv_linemeter.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_linemeter.h" +#if LV_USE_LINEMETER != 0 + +#include "../lv_misc/lv_debug.h" +#include "../lv_draw/lv_draw.h" +#include "../lv_themes/lv_theme.h" +#include "../lv_core/lv_group.h" +#include "../lv_misc/lv_math.h" + +/********************* + * DEFINES + *********************/ +#define LV_OBJX_NAME "lv_linemeter" + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static lv_design_res_t lv_linemeter_design(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_design_mode_t mode); +static lv_res_t lv_linemeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param); + +/********************** + * STATIC VARIABLES + **********************/ +static lv_signal_cb_t ancestor_signal; + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Create a line meter objects + * @param par pointer to an object, it will be the parent of the new line meter + * @param copy pointer to a line meter object, if not NULL then the new object will be copied from + * it + * @return pointer to the created line meter + */ +lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy) +{ + LV_LOG_TRACE("line meter create started"); + + /*Create the ancestor of line meter*/ + lv_obj_t * linemeter = lv_obj_create(par, copy); + LV_ASSERT_MEM(linemeter); + if(linemeter == NULL) return NULL; + + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(linemeter); + + /*Allocate the line meter type specific extended data*/ + lv_linemeter_ext_t * ext = lv_obj_allocate_ext_attr(linemeter, sizeof(lv_linemeter_ext_t)); + LV_ASSERT_MEM(ext); + if(ext == NULL) { + lv_obj_del(linemeter); + return NULL; + } + + /*Initialize the allocated 'ext' */ + ext->min_value = 0; + ext->max_value = 100; + ext->cur_value = 0; + ext->line_cnt = 18; + ext->scale_angle = 240; + ext->angle_ofs = 0; + ext->mirrored = 0; + + /*The signal and design functions are not copied so set them here*/ + lv_obj_set_signal_cb(linemeter, lv_linemeter_signal); + lv_obj_set_design_cb(linemeter, lv_linemeter_design); + + /*Init the new line meter line meter*/ + if(copy == NULL) { + lv_obj_set_size(linemeter, 3 * LV_DPI / 2, 3 * LV_DPI / 2); + lv_theme_apply(linemeter, LV_THEME_LINEMETER); + } + /*Copy an existing line meter*/ + else { + lv_linemeter_ext_t * copy_ext = lv_obj_get_ext_attr(copy); + ext->scale_angle = copy_ext->scale_angle; + ext->line_cnt = copy_ext->line_cnt; + ext->min_value = copy_ext->min_value; + ext->max_value = copy_ext->max_value; + ext->cur_value = copy_ext->cur_value; + + /*Refresh the style with new signal function*/ + lv_obj_refresh_style(linemeter, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + } + + LV_LOG_INFO("line meter created"); + + return linemeter; +} + +/*===================== + * Setter functions + *====================*/ + +/** + * Set a new value on the line meter + * @param lmeter pointer to a line meter object + * @param value new value + */ +void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + if(ext->cur_value == value) return; + + int32_t old_value = ext->cur_value; + + ext->cur_value = value > ext->max_value ? ext->max_value : value; + ext->cur_value = ext->cur_value < ext->min_value ? ext->min_value : ext->cur_value; + + int16_t level_old = + (int32_t)((int32_t)(old_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); + int16_t level_new = + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); + + if(level_new == level_old) { + return; + } + + lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LINEMETER_PART_MAIN); + lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LINEMETER_PART_MAIN); + lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LINEMETER_PART_MAIN); + lv_style_int_t bottom = lv_obj_get_style_pad_bottom(lmeter, LV_LINEMETER_PART_MAIN); + + lv_coord_t r_out = (lv_obj_get_width(lmeter) - left - right) / 2 ; + lv_coord_t r_in = r_out - lv_obj_get_style_scale_width(lmeter, LV_LINEMETER_PART_MAIN); + if(r_in < 1) r_in = 1; + + lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left; + lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top; + int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2; + + lv_style_int_t line_width = lv_obj_get_style_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN); + lv_style_int_t end_line_width = lv_obj_get_style_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN); + line_width = LV_MATH_MAX(line_width, end_line_width); + + int32_t angle_old = (level_old * ext->scale_angle) / (ext->line_cnt - 1); + + /*Use smaller clip area only around the visible line*/ + int32_t y_in_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; + int32_t x_in_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; + + + int32_t y_out_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; + int32_t x_out_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; + + + + int32_t angle_new = (level_new * ext->scale_angle) / (ext->line_cnt - 1); + + /*Use smaller clip area only around the visible line*/ + int32_t y_in_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; + int32_t x_in_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; + + + int32_t y_out_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; + int32_t x_out_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; + + lv_area_t a; + if(x_out_old < 0 && x_out_new < 0) { + a.x1 = lmeter->coords.x1 + left - line_width; + a.y1 = LV_MATH_MIN4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs - line_width; + a.x2 = LV_MATH_MAX(x_in_old, x_in_new) + x_ofs + line_width; + a.y2 = LV_MATH_MAX4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs + line_width; + } + else if(x_out_old > 0 && x_out_new > 0) { + a.x1 = LV_MATH_MIN(x_in_old, x_in_new) + x_ofs - line_width; + a.y1 = LV_MATH_MIN4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs - line_width; + a.x2 = lmeter->coords.x2 - right + line_width; + a.y2 = LV_MATH_MAX4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs + line_width; + } + else if(y_out_old < 0 && y_out_new < 0) { + a.x1 = LV_MATH_MIN4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs - line_width; + a.y1 = lmeter->coords.y1 + top - line_width; + a.x2 = LV_MATH_MAX4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs + line_width; + a.y2 = LV_MATH_MAX(y_in_old, y_in_new) + y_ofs + line_width; + } + else if(y_out_old > 0 && y_out_new > 0) { + a.x1 = LV_MATH_MIN4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs - line_width; + a.y1 = LV_MATH_MIN(y_in_old, y_in_new) + y_ofs - line_width; + a.x2 = LV_MATH_MAX4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs + line_width; + a.y2 = lmeter->coords.y2 - bottom + line_width; + } + else { + a.x1 = lmeter->coords.x1 + left - line_width; + a.y1 = lmeter->coords.y1 + top - line_width; + a.x2 = lmeter->coords.x2 - right + line_width; + a.y2 = lmeter->coords.y2 - bottom + line_width; + } + + lv_obj_invalidate_area(lmeter, &a); + +} + +/** + * Set minimum and the maximum values of a line meter + * @param lmeter pointer to he line meter object + * @param min minimum value + * @param max maximum value + */ +void lv_linemeter_set_range(lv_obj_t * lmeter, int32_t min, int32_t max) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + if(ext->min_value == min && ext->max_value == max) return; + + ext->max_value = max; + ext->min_value = min; + if(ext->cur_value > max) { + ext->cur_value = max; + lv_linemeter_set_value(lmeter, ext->cur_value); + } + if(ext->cur_value < min) { + ext->cur_value = min; + lv_linemeter_set_value(lmeter, ext->cur_value); + } + lv_obj_invalidate(lmeter); +} + +/** + * Set the scale settings of a line meter + * @param lmeter pointer to a line meter object + * @param angle angle of the scale (0..360) + * @param line_cnt number of lines + */ +void lv_linemeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + if(ext->scale_angle == angle && ext->line_cnt == line_cnt) return; + + ext->scale_angle = angle; + ext->line_cnt = line_cnt; + + lv_obj_invalidate(lmeter); +} + +/** + * Set the set an offset for the line meter's angles to rotate it. + * @param lmeter pointer to a line meter object + * @param angle angle where the meter will be facing (with its center) + */ +void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle) +{ + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + if(ext->angle_ofs == angle) return; + + ext->angle_ofs = angle; + + lv_obj_invalidate(lmeter); +} + +/** + * Set the orientation of the meter growth, clockwise or counterclockwise (mirrored) + * @param lmeter pointer to a line meter object + * @param mirror mirror setting + */ +void lv_linemeter_set_mirror(lv_obj_t * lmeter, bool mirror) +{ + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + if(ext->mirrored == mirror) return; + + ext->mirrored = mirror; + + lv_obj_invalidate(lmeter); +} + +/*===================== + * Getter functions + *====================*/ + +/** + * Get the value of a line meter + * @param lmeter pointer to a line meter object + * @return the value of the line meter + */ +int32_t lv_linemeter_get_value(const lv_obj_t * lmeter) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + return ext->cur_value; +} + +/** + * Get the minimum value of a line meter + * @param lmeter pointer to a line meter object + * @return the minimum value of the line meter + */ +int32_t lv_linemeter_get_min_value(const lv_obj_t * lmeter) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + return ext->min_value; +} + +/** + * Get the maximum value of a line meter + * @param lmeter pointer to a line meter object + * @return the maximum value of the line meter + */ +int32_t lv_linemeter_get_max_value(const lv_obj_t * lmeter) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + return ext->max_value; +} + +/** + * Get the scale number of a line meter + * @param lmeter pointer to a line meter object + * @return number of the scale units + */ +uint16_t lv_linemeter_get_line_count(const lv_obj_t * lmeter) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + return ext->line_cnt; +} + +/** + * Get the scale angle of a line meter + * @param lmeter pointer to a line meter object + * @return angle_ofs of the scale + */ +uint16_t lv_linemeter_get_scale_angle(const lv_obj_t * lmeter) +{ + LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); + + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + return ext->scale_angle; +} + +/** + * Get the offset for the line meter. + * @param lmeter pointer to a line meter object + * @return angle offset (0..360) + */ +uint16_t lv_linemeter_get_angle_offset(lv_obj_t * lmeter) +{ + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + + return ext->angle_ofs; +} + +/** + * get the mirror setting for the line meter + * @param lmeter pointer to a line meter object + * @return mirror (true or false) + */ +bool lv_linemeter_get_mirror(lv_obj_t * lmeter) +{ + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + + return ext->mirrored; +} + +void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part) +{ + lv_linemeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + + lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LINEMETER_PART_MAIN); + lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LINEMETER_PART_MAIN); + lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LINEMETER_PART_MAIN); + + lv_coord_t r_out = (lv_obj_get_width(lmeter) - left - right) / 2 ; + lv_coord_t r_in = r_out - lv_obj_get_style_scale_width(lmeter, part); + if(r_in < 1) r_in = 1; + + lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left; + lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top; + int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2; + int16_t level = ext->mirrored ? + (int32_t)((int32_t)(ext->max_value - ext->cur_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value) : + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); + uint8_t i; + + lv_color_t main_color = lv_obj_get_style_line_color(lmeter, part); + lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part); + lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part); + + lv_draw_line_dsc_t line_dsc; + lv_draw_line_dsc_init(&line_dsc); + lv_obj_init_draw_line_dsc(lmeter, part, &line_dsc); +#if LV_LINEMETER_PRECISE == 2 + line_dsc.raw_end = 1; +#endif + + lv_style_int_t end_line_width = lv_obj_get_style_scale_end_line_width(lmeter, part); + +#if LV_LINEMETER_PRECISE > 0 + lv_area_t mask_area; + mask_area.x1 = x_ofs - r_in; + mask_area.x2 = x_ofs + r_in - 1; + mask_area.y1 = y_ofs - r_in; + mask_area.y2 = y_ofs + r_in - 1; + + lv_draw_mask_radius_param_t mask_in_param; + lv_draw_mask_radius_init(&mask_in_param, &mask_area, LV_RADIUS_CIRCLE, true); + int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, 0); +#endif + + +#if LV_LINEMETER_PRECISE > 1 + mask_area.x1 = x_ofs - r_out; + mask_area.x2 = x_ofs + r_out - 1; + mask_area.y1 = y_ofs - r_out; + mask_area.y2 = y_ofs + r_out - 1; + lv_draw_mask_radius_param_t mask_out_param; + lv_draw_mask_radius_init(&mask_out_param, &mask_area, LV_RADIUS_CIRCLE, false); + int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0); + /*In calculation use a larger radius to avoid rounding errors */ + lv_coord_t r_out_extra = r_out + LV_DPI; +#else + lv_coord_t r_out_extra = r_out; +#endif + + for(i = 0; i < ext->line_cnt; i++) { + /* `* 256` for extra precision*/ + int32_t angle_upscale = (i * ext->scale_angle * 256) / (ext->line_cnt - 1); + int32_t angle_normal = angle_upscale >> 8; + + int32_t angle_low = (angle_upscale >> 8); + int32_t angle_high = angle_low + 1; + int32_t angle_rem = angle_upscale & 0xFF; + + /*Interpolate sine and cos*/ + int32_t sin_low = _lv_trigo_sin(angle_low + angle_ofs); + int32_t sin_high = _lv_trigo_sin(angle_high + angle_ofs); + int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8; + + int32_t cos_low = _lv_trigo_sin(angle_low + 90 + angle_ofs); + int32_t cos_high = _lv_trigo_sin(angle_high + 90 + angle_ofs); + int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8; + + /*Use the interpolated values to get x and y coordinates*/ + int32_t y_out_extra = (int32_t)((int32_t)sin_mid * r_out_extra) >> (LV_TRIGO_SHIFT - 8); + int32_t x_out_extra = (int32_t)((int32_t)cos_mid * r_out_extra) >> (LV_TRIGO_SHIFT - 8); + + /*Rounding*/ + if(x_out_extra > 0) x_out_extra = (x_out_extra + 127) >> 8; + else x_out_extra = (x_out_extra - 127) >> 8; + + if(y_out_extra > 0) y_out_extra = (y_out_extra + 127) >> 8; + else y_out_extra = (y_out_extra - 127) >> 8; + + x_out_extra += x_ofs; + y_out_extra += y_ofs; + + /*With no extra precision use the coordinates on the inner radius*/ +#if LV_LINEMETER_PRECISE == 0 + /*Use the interpolated values to get x and y coordinates*/ + int32_t y_in_extra = (int32_t)((int32_t)sin_mid * r_in) >> (LV_TRIGO_SHIFT - 8); + int32_t x_in_extra = (int32_t)((int32_t)cos_mid * r_in) >> (LV_TRIGO_SHIFT - 8); + + /*Rounding*/ + if(x_in_extra > 0) x_in_extra = (x_in_extra + 127) >> 8; + else x_in_extra = (x_in_extra - 127) >> 8; + + if(y_in_extra > 0) y_in_extra = (y_in_extra + 127) >> 8; + else y_in_extra = (y_in_extra - 127) >> 8; + + x_in_extra += x_ofs; + y_in_extra += y_ofs; +#else + int32_t x_in_extra = x_ofs; + int32_t y_in_extra = y_ofs; +#endif + + /*Use smaller clip area only around the visible line*/ + int32_t y_in = (int32_t)((int32_t)_lv_trigo_sin(angle_normal + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; + int32_t x_in = (int32_t)((int32_t)_lv_trigo_sin(angle_normal + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; + + x_in += x_ofs; + y_in += y_ofs; + + int32_t y_out = (int32_t)((int32_t)_lv_trigo_sin(angle_normal + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; + int32_t x_out = (int32_t)((int32_t)_lv_trigo_sin(angle_normal + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; + + x_out += x_ofs; + y_out += y_ofs; + + lv_area_t clip_sub; + clip_sub.x1 = LV_MATH_MIN(x_in, x_out) - line_dsc.width; + clip_sub.x2 = LV_MATH_MAX(x_in, x_out) + line_dsc.width; + clip_sub.y1 = LV_MATH_MIN(y_in, y_out) - line_dsc.width; + clip_sub.y2 = LV_MATH_MAX(y_in, y_out) + line_dsc.width; + + if(_lv_area_intersect(&clip_sub, &clip_sub, clip_area) == false) continue; + + lv_point_t p1; + lv_point_t p2; + + p2.x = x_in_extra; + p2.y = y_in_extra; + + p1.x = x_out_extra; + p1.y = y_out_extra; + + /* Set the color of the lines */ + if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) { + line_dsc.color = end_color; + line_dsc.width = end_line_width; + } + else { + line_dsc.color = lv_color_mix(grad_color, main_color, (255 * i) / ext->line_cnt); + } + + lv_draw_line(&p1, &p2, &clip_sub, &line_dsc); + } + +#if LV_LINEMETER_PRECISE > 0 + lv_draw_mask_remove_id(mask_in_id); +#endif + +#if LV_LINEMETER_PRECISE > 1 + lv_draw_mask_remove_id(mask_out_id); +#endif + + if(part == LV_LINEMETER_PART_MAIN && level < ext->line_cnt - 1) { + lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part); + lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part); + + if(border_width || end_border_width) { + int16_t end_angle = ((level) * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs; + lv_draw_line_dsc_t arc_dsc; + lv_draw_line_dsc_init(&arc_dsc); + lv_obj_init_draw_line_dsc(lmeter, part, &arc_dsc); + + if(border_width) { + arc_dsc.width = border_width; + arc_dsc.color = main_color; + lv_draw_arc(x_ofs, y_ofs, r_out, angle_ofs, end_angle, clip_area, &arc_dsc); + } + + if(end_border_width) { + arc_dsc.width = end_border_width; + arc_dsc.color = end_color; + lv_draw_arc(x_ofs, y_ofs, r_out, end_angle, (angle_ofs + ext->scale_angle) % 360, clip_area, &arc_dsc); + } + } + } + + +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +/** + * Handle the drawing related tasks of the line meters + * @param lmeter pointer to an object + * @param clip_area the object will be drawn only in this area + * @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area + * (return 'true' if yes) + * LV_DESIGN_DRAW: draw the object (always return 'true') + * LV_DESIGN_DRAW_POST: drawing after every children are drawn + * @param return an element of `lv_design_res_t` + */ +static lv_design_res_t lv_linemeter_design(lv_obj_t * lmeter, const lv_area_t * clip_area, lv_design_mode_t mode) +{ + /*Return false if the object is not covers the mask_p area*/ + if(mode == LV_DESIGN_COVER_CHK) { + return LV_DESIGN_RES_NOT_COVER; + } + /*Draw the object*/ + else if(mode == LV_DESIGN_DRAW_MAIN) { + lv_draw_rect_dsc_t bg_dsc; + lv_draw_rect_dsc_init(&bg_dsc); + lv_obj_init_draw_rect_dsc(lmeter, LV_LINEMETER_PART_MAIN, &bg_dsc); + lv_draw_rect(&lmeter->coords, clip_area, &bg_dsc); + lv_linemeter_draw_scale(lmeter, clip_area, LV_LINEMETER_PART_MAIN); + } + /*Post draw when the children are drawn*/ + else if(mode == LV_DESIGN_DRAW_POST) { + } + + return LV_DESIGN_RES_OK; +} + +/** + * Signal function of the line meter + * @param lmeter pointer to a line meter object + * @param sign a signal type from lv_signal_t enum + * @param param pointer to a signal specific variable + * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted + */ +static lv_res_t lv_linemeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param) +{ + lv_res_t res; + + /* Include the ancient signal function */ + res = ancestor_signal(lmeter, 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_CLEANUP) { + /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/ + } + else if(sign == LV_SIGNAL_STYLE_CHG) { + lv_obj_refresh_ext_draw_pad(lmeter); + lv_obj_invalidate(lmeter); + } + + return res; +} +#endif diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index de18041d4..5f1d98154 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -152,8 +152,7 @@ static lv_design_res_t lv_slider_design(lv_obj_t * slider, const lv_area_t * cli } /*Draw the object*/ else if(mode == LV_DESIGN_DRAW_MAIN) { - - /*The ancestor design function will draw the background and the indicator. + /* The ancestor design function will draw the background and the indicator. * It also sets ext->bar.indic_area*/ ancestor_design(slider, clip_area, mode); diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index b71135176..501af6a24 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -947,29 +947,16 @@ static lv_style_list_t * lv_table_get_style(lv_obj_t * table, uint8_t part) LV_ASSERT_OBJ(table, LV_OBJX_NAME); lv_table_ext_t * ext = lv_obj_get_ext_attr(table); - lv_style_list_t * style_dsc_p; - switch(part) { - case LV_TABLE_PART_BG: - style_dsc_p = &table->style_list; - break; - case LV_TABLE_PART_CELL1: - style_dsc_p = &ext->cell_style[0]; - break; - case LV_TABLE_PART_CELL2: - style_dsc_p = &ext->cell_style[1]; - break; - case LV_TABLE_PART_CELL3: - style_dsc_p = &ext->cell_style[2]; - break; - case LV_TABLE_PART_CELL4: - style_dsc_p = &ext->cell_style[3]; - break; - default: - style_dsc_p = NULL; + /* Because of the presence of LV_TABLE_PART_BG, LV_TABLE_PART_CELL has an integer value + of . This comes in useful to extend above code with more cell types as follows */ + if ( part == LV_TABLE_PART_BG ) { + return &table->style_list; + } else if (part >= 1 && part <= LV_TABLE_CELL_STYLE_CNT ) { + return &ext->cell_style[part-1]; } - return style_dsc_p; + return NULL; } static void refr_size(lv_obj_t * table) diff --git a/src/lv_widgets/lv_table.h b/src/lv_widgets/lv_table.h index 58995d60f..d05f2ce9a 100644 --- a/src/lv_widgets/lv_table.h +++ b/src/lv_widgets/lv_table.h @@ -32,7 +32,17 @@ extern "C" { #define LV_TABLE_COL_MAX 12 #endif -#define LV_TABLE_CELL_STYLE_CNT 4 +/* + Maximum allowable value of LV_TABLE_CELL_STYLE_CNT is 16 + because of restriction of lv_table_cell_format_t.type to no more than + 4 bits so that lv_table_cell_format_t.s will not exceed 8 bits +*/ +#ifndef LV_TABLE_CELL_STYLE_CNT +# define LV_TABLE_CELL_STYLE_CNT 4 +#endif +#if (LV_TABLE_CELL_STYLE_CNT > 16) +# error LV_TABLE_CELL_STYLE_CNT cannot exceed 16 +#endif /********************** * TYPEDEFS **********************/ @@ -46,7 +56,7 @@ typedef union { struct { uint8_t align : 2; uint8_t right_merge : 1; - uint8_t type : 2; + uint8_t type : 4; // upto 16 values uint8_t crop : 1; } s; uint8_t format_byte; @@ -61,16 +71,17 @@ typedef struct { lv_coord_t * row_h; lv_style_list_t cell_style[LV_TABLE_CELL_STYLE_CNT]; lv_coord_t col_w[LV_TABLE_COL_MAX]; - uint8_t cell_types : 4; /*Keep track which cell types exists to avoid dealing with unused ones*/ + uint16_t cell_types : LV_TABLE_CELL_STYLE_CNT; /*Keep track which cell types exists to avoid dealing with unused ones*/ } lv_table_ext_t; /*Parts of the table*/ enum { - LV_TABLE_PART_BG, - LV_TABLE_PART_CELL1, - LV_TABLE_PART_CELL2, + LV_TABLE_PART_BG, /* Because of this member, LV_PART.*CELL1 has enum value of 1, */ + LV_TABLE_PART_CELL1, /* LV_PART.*CELL2 has an enum value of 2 and so on upto the maximum */ + LV_TABLE_PART_CELL2, /* number of styles specified by LV_TABLE_CELL_STYLE_CNT */ LV_TABLE_PART_CELL3, - LV_TABLE_PART_CELL4, + LV_TABLE_PART_CELL4, /* CELL 5-16 are not needed to be defined, the values in this enum + are there for backward compatibility */ }; /********************** diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index f922e2264..2b1489462 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -286,19 +286,24 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) #if LV_USE_ANIMATION /*Auto hide characters*/ - lv_anim_path_t path; - lv_anim_path_init(&path); - lv_anim_path_set_cb(&path, lv_anim_path_step); + if(ext->pwd_show_time == 0) { + pwd_char_hider(ta); + } + else { + lv_anim_path_t path; + lv_anim_path_init(&path); + lv_anim_path_set_cb(&path, lv_anim_path_step); - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, ta); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim); - lv_anim_set_time(&a, ext->pwd_show_time); - lv_anim_set_values(&a, 0, 1); - lv_anim_set_path(&a, &path); - lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready); - lv_anim_start(&a); + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, ta); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim); + lv_anim_set_time(&a, ext->pwd_show_time); + lv_anim_set_values(&a, 0, 1); + lv_anim_set_path(&a, &path); + lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready); + lv_anim_start(&a); + } #else pwd_char_hider(ta); @@ -364,18 +369,24 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) #if LV_USE_ANIMATION /*Auto hide characters*/ - lv_anim_path_t path; - lv_anim_path_init(&path); - lv_anim_path_set_cb(&path, lv_anim_path_step); - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, ta); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim); - lv_anim_set_time(&a, ext->pwd_show_time); - lv_anim_set_values(&a, 0, 1); - lv_anim_set_path(&a, &path); - lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready); - lv_anim_start(&a); + if(ext->pwd_show_time == 0) { + pwd_char_hider(ta); + } + else { + lv_anim_path_t path; + lv_anim_path_init(&path); + lv_anim_path_set_cb(&path, lv_anim_path_step); + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, ta); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim); + lv_anim_set_time(&a, ext->pwd_show_time); + lv_anim_set_values(&a, 0, 1); + lv_anim_set_path(&a, &path); + lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready); + lv_anim_start(&a); + } #else pwd_char_hider(ta); #endif @@ -516,19 +527,24 @@ void lv_textarea_set_text(lv_obj_t * ta, const char * txt) #if LV_USE_ANIMATION /*Auto hide characters*/ - lv_anim_path_t path; - lv_anim_path_init(&path); - lv_anim_path_set_cb(&path, lv_anim_path_step); + if(ext->pwd_show_time == 0) { + pwd_char_hider(ta); + } + else { + lv_anim_path_t path; + lv_anim_path_init(&path); + lv_anim_path_set_cb(&path, lv_anim_path_step); - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, ta); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim); - lv_anim_set_time(&a, ext->pwd_show_time); - lv_anim_set_values(&a, 0, 1); - lv_anim_set_path(&a, &path); - lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready); - lv_anim_start(&a); + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, ta); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim); + lv_anim_set_time(&a, ext->pwd_show_time); + lv_anim_set_values(&a, 0, 1); + lv_anim_set_path(&a, &path); + lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready); + lv_anim_start(&a); + } #else pwd_char_hider(ta); #endif diff --git a/tests/lv_test_core/lv_test_font_loader.c b/tests/lv_test_core/lv_test_font_loader.c index 3b3f6321a..7158d0823 100644 --- a/tests/lv_test_core/lv_test_font_loader.c +++ b/tests/lv_test_core/lv_test_font_loader.c @@ -28,7 +28,7 @@ * STATIC PROTOTYPES **********************/ -#if LV_USE_FILESYSTEM && LV_FONT_FMT_TXT_LARGE == 0 +#if LV_USE_FILESYSTEM static int compare_fonts(lv_font_t * f1, lv_font_t * f2); #endif @@ -50,7 +50,7 @@ extern lv_font_t font_3; void lv_test_font_loader(void) { -#if LV_USE_FILESYSTEM && LV_FONT_FMT_TXT_LARGE == 0 +#if LV_USE_FILESYSTEM lv_font_t * font_1_bin = lv_font_load("f:font_1.fnt"); lv_font_t * font_2_bin = lv_font_load("f:font_2.fnt"); lv_font_t * font_3_bin = lv_font_load("f:font_3.fnt"); @@ -67,7 +67,7 @@ void lv_test_font_loader(void) #endif } -#if LV_USE_FILESYSTEM && LV_FONT_FMT_TXT_LARGE == 0 +#if LV_USE_FILESYSTEM static int compare_fonts(lv_font_t * f1, lv_font_t * f2) { lv_test_assert_true(f1 != NULL && f2 != NULL, "font not null");