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

Merge branch 'dev-5.2' of https://github.com/littlevgl/lvgl into dev-5.2

This commit is contained in:
Gabor Kiss-Vamosi 2018-09-21 12:19:11 +02:00
commit 64d1fcbe9c
74 changed files with 2401 additions and 657 deletions

View File

@ -1,6 +1,6 @@
# Littlev Graphics Libraray
# Littlev Graphics Library
![LittlevGL cover](http://www.gl.littlev.hu/home/main_cover_small.png)
![LittlevGL cover](https://littlevgl.com/docs/themes/lv_theme_intro.png)
LittlevGL provides everything you need to create a Graphical User Interface (GUI) on embedded systems with easy-to-use graphical elements, beautiful visual effects and low memory footprint.
@ -11,18 +11,19 @@ Homepage: https://littlevgl.com
* [Porting](#porting)
* [Project set-up](#project-set-up)
* [PC simulator](#pc-simulator)
* [Related repositories](#related-repositories)
* [Screenshots](#screenshots)
* [Contributing](#contributing)
* [Donate](#donate)
## Key features
* Powerful building blocks buttons, charts, lists, sliders, images etc
* Powerful building blocks: buttons, charts, lists, sliders, images, etc.
* Advanced graphics with animations, anti-aliasing, opacity, smooth scrolling
* Various input devices touch pad, mouse, keyboard, encoder, buttons etc
* Multi language support with UTF-8 decoding
* Various input devices: touch pad, mouse, keyboard, encoder, buttons, etc.
* Multi-language support with UTF-8 encoding
* Fully customizable graphical elements
* Hardware independent to use with any microcontroller or display
* Scalable to operate with few memory (50 kB Flash, 10 kB RAM)
* Scalable to operate with little memory (50 kB Flash, 10 kB RAM)
* OS, External memory and GPU supported but not required
* Single frame buffer operation even with advances graphical effects
* Written in C for maximal compatibility
@ -31,19 +32,20 @@ Homepage: https://littlevgl.com
* Documentation and API references online
## Porting
In the most sime case you need 4 things:
1. Call `lv_tick_inc(1)` in every millisecods in a Timer or Task
In the simplest case you need 5 things:
1. Call `lv_tick_inc(x)` every `x` milliseconds in a Timer or Task (`x` should be between 1 and 10)
2. Register a function which can **copy a pixel array** to an area of the screen.
3. Register a function which can **read an input device**. (E.g. touch pad)
4. Call `lv_task_handler()` periodically in every few milliseconds
For more information visit https://littlevgl.com/porting
4. Copy `lv_conf_templ.h` as `lv_conf.h` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`.
5. Call `lv_task_handler()` periodically every few milliseconds.
For a detailed description visit https://littlevgl.com/porting
Or check the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
## Project set-up
1. **Clone** or [Download](https://littlevgl.com/download) the lvgl repository: `git clone https://github.com/littlevgl/lvgl.git`
2. **Create project** with your prefered IDE and add the *lvgl* folder
2. **Create project** with your preferred IDE and add the *lvgl* folder
3. Copy **lvgl/lv_conf_templ.h** as **lv_conf.h** next to the *lvgl* folder
4. In the lv_conf.h delete the first `#if 0` and its `#endif`. Let the default configurations at first.
4. In the lv_conf.h delete the first `#if 0` and its `#endif`. Leave the default configuration for the first try.
5. In your *main.c*: #include "lvgl/lvgl.h"
6. In your *main function*:
* lvgl_init();
@ -53,10 +55,16 @@ Or check the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/ma
9. Compile the code and load it to your embedded hardware
## PC Simulator
If you don't have got an embedded hardware you can test the graphics library in a PC simulator. The simulator uses [SDL2](https://www.libsdl.org/) to emulate a display on your monitor and a touch pad with your mouse.
You can test the graphics library in a PC simulator, if you don't have an embedded hardware. The simulator uses [SDL2](https://www.libsdl.org/) library to emulate a display on your monitor and a touch pad with your mouse.
There is a pre-configured PC project for **Eclipse CDT** in this repository: https://github.com/littlevgl/pc_simulator
## Related repositories
* PC simulator: https://github.com/littlevgl/pc_simulator
* Projects: https://github.com/littlevgl/lv_projects
* Examples: https://github.com/littlevgl/lv_examples
* Drivers: https://github.com/littlevgl/lv_drivers
## Screenshots
![TFT material](http://www.gl.littlev.hu/github_res/tft_material.png)
![TFT zen](http://www.gl.littlev.hu/github_res/tft_zen.png)
@ -67,6 +75,6 @@ There is a pre-configured PC project for **Eclipse CDT** in this repository: htt
See [CONTRIBUTING.md](https://github.com/littlevgl/lvgl/blob/master/docs/CONTRIBUTING.md)
## Donate
If you are pleased with the graphics library, found it useful or be happy with the support you got, please help its further development:
If you are pleased with this graphics library, found it useful, or are happy with the support you got, please help its further development:
[![Donate](https://littlevgl.com/donate_dir/donate_btn.png)](https://littlevgl.com/donate)

View File

@ -22,13 +22,13 @@ Please, take a look at [CODE_OF_CONDUCT](https://github.com/littlevgl/lvgl/blob/
There are few **general rules**
* We use [GitHub's issue tracker](https://github.com/littlevgl/lvgl/issues)
* Be kind and respectful. Strating with "Hi" is always a good idea :)
* If somebedy helped you give a feedback.
* Be kind and respectful. Starting with "Hi" is always a good idea :)
* If somebody helped you give a feedback.
* One issue should be about one topic. If you have other questions please open a new issue.
* Always create an issue before creating a [Pull request](https://help.github.com/articles/about-pull-requests/) to discuss the idea first
* Create small, "digestable" Pull requests.
* Create small, "digestible" Pull requests.
* Tell your remarks in a structured way. Use paragraphs and the [Markdown](https://guides.github.com/features/mastering-markdown/) support of GitHub.
* Be sure you are using the lates version (from `master` branch)
* Be sure you are using the latest version (from `master` branch)
* Keep in mind LittlevGL should be and should remain:
- usable on small MCUs as well (think about memory footprint)
- compilable with "non-standard" tools like Arduino (no gcc specific options)
@ -43,12 +43,12 @@ If you found a **simple and straightforward bug** like:
* anything else which can be fixed locally with a few lines of code
* or defective documentation
then tell
then tell:
* where you found the bug (which file/function/variable)
* how can it cause problem
* what is your suggeseted solution if you have
* what is your suggested solution if you have
If you faced with **something more clomplex** like:
If you faced with **something more complex** like:
* might be simple but you don't know its origin
* affects a whole file, module or even the architecture
* needs deeper discussion
@ -57,7 +57,7 @@ then please
* tell what do you experience
* tell what do you expect to happen
* tell how to reproduce the issue
* provide a simlified code example (better if can be tested with copy-paste)
* provide a simplified code example (better if can be tested with copy-paste)
* attache your lv_conf.h (if you feel it's important)
* logs and long codes should be attached in a file (instead of copying into a comment)
@ -69,16 +69,16 @@ If you have a good and useful idea open issue to tell it! Please note the follow
* Can you help in implementing it?
Your suggestion can have 4 possible outcomes:
1. This feature is already exists. In this case you will learn how to achive your goal.
1. This feature is already exists. In this case you will learn how to achieve your goal.
2. You can simply realize it with the current functionality.
3. Although it's a new feature but it would break LittlevGL's platform independent and/or resource minimalist nature.
4. It's really a new feature which would be good to be in LittlevGL. Hurray! In a discussion we figure out the technical details and implementation options. With the knowledge of how to do it somebody can implement the new feature.
Keep in mind if you wouldn't like to do the implementation there is no guarantee that it will be ready in the near future.
However if you would like to force it, take a look at this page: [Feature request service](http://www.gl.littlev.hu/services#feature)
However, if you would like to force it, take a look at this page: [Feature request service](http://www.gl.littlev.hu/services#feature)
## How to implement a feature?
In [docs/TODO_MINOR.md](https://github.com/littlevgl/lvgl/blob/master/docs/TODO_MINOR.md) and [docs/TODO_PATCH.md](https://github.com/littlevgl/lvgl/blob/master/docs/TODO_PATCH.md) you can see some ideas which are waiting for somebody to realize them! If want to deal with a feature from this files, please start an issue and discusse the details.
In [docs/TODO_MINOR.md](https://github.com/littlevgl/lvgl/blob/master/docs/TODO_MINOR.md) and [docs/TODO_PATCH.md](https://github.com/littlevgl/lvgl/blob/master/docs/TODO_PATCH.md) you can see some ideas which are waiting for somebody to realize them! If want to deal with a feature from these files, please start an issue and discuss the details.
The new feature should be in a new branch.
@ -88,7 +88,7 @@ The new feature should be in a new branch.
Use [lv_misc/lv_templ.c](https://github.com/littlevgl/lvgl/blob/master/lv_misc/lv_templ.c) and [lv_misc/lv_templ.h](https://github.com/littlevgl/lvgl/blob/master/lv_misc/lv_templ.h)
### Naming conventions
* Words are sparated by '_'
* Words are separated by '_'
* In variable and function names use only lower case letters (e.g. *height_tmp*)
* In enums and defines use only upper case letters (e.g. *e.g. MAX_LINE_NUM*)
* Global names (API):
@ -100,13 +100,13 @@ Use [lv_misc/lv_templ.c](https://github.com/littlevgl/lvgl/blob/master/lv_misc/l
* prefer `typedef struct` and `typedef enum` instead of `struct name` and `enum name`
* always add a closing *..._t*
* Abbreviations:
* Use abbreviations on public names only if they become longer then 32 characters
* Use only very straightforward (e.g. pos: position) or well established (e.g. pr: press) abbreviatons
* Use abbreviations on public names only if they become longer than 32 characters
* Use only very straightforward (e.g. pos: position) or well-established (e.g. pr: press) abbreviations
### Coding guide
* Functions:
* Try to write function shorter then is 50 lines
* Always shorter then 100 lines (except very straightforwards)
* Try to write function shorter than is 50 lines
* Always shorter than 100 lines (except very straightforwards)
* Variables:
* One line, one declaration (BAD: char x, y;)
* Use `<stdint.h>` (*uint8_t*, *int32_t* etc)
@ -138,7 +138,7 @@ You should write **why** have you done this:
Short "code summaries" of a few lines are accepted. E.g. `/*Calculate the new coordinates*/`
In comments use \` \` when refering to a variable. E.g. ``/*Update the value of `x_act`*/``
In comments use \` \` when referring to a variable. E.g. ``/*Update the value of `x_act`*/``
### Formatting
Here is example to show bracket placing and using of white spaces:
@ -149,7 +149,7 @@ Here is example to show bracket placing and using of white spaces:
* @param text '\0' terminated character string. NULL to refresh with the current text.
*/
void lv_label_set_text(lv_obj_t * label, const char * text)
{ /* Main bracket of functions in new line*/
{ /* Main brackets of functions in new line*/
if(label == NULL) return; /*No bracket only if the command is inline with the if statement*/

View File

@ -38,14 +38,14 @@
* Required for buffered drawing, opacity and anti-aliasing
* VDB makes the double buffering, you don't need to deal with it!
* Typical size: ~1/10 screen */
#define LV_VDB_SIZE (8 * LV_HOR_RES) /*Size of VDB in pixel count (1/10 screen size is good for first)*/
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. (Set `disp_drv->vdb_wr` and `disp_drv->vdb_rd` too)*/
#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate automatically into RAM)*/
#define LV_VDB_SIZE (30 * LV_HOR_RES) /*Size of VDB in pixel count (1/10 screen size is good for first)*/
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. (Set `disp_drv->vdb_wr` and `disp_drv->vdb_rd` too)*/
#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate automatically into RAM; LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`)*/
/* Use two Virtual Display buffers (VDB) parallelize rendering and flushing (optional)
* The flushing should use DMA to write the frame buffer in the background*/
#define LV_VDB_DOUBLE 0 /*1: Enable the use of 2 VDBs*/
#define LV_VDB2_ADR 0 /*Place VDB2 to a specific address (e.g. in external RAM) (0: allocate automatically into RAM)*/
#define LV_VDB2_ADR 0 /*Place VDB2 to a specific address (e.g. in external RAM) (0: allocate automatically into RAM; LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`)*/
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
@ -67,8 +67,9 @@
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
/*Color settings*/
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/24*/
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
/*Text settings*/
@ -125,6 +126,7 @@
#define USE_LV_THEME_MONO 0 /*Mono color theme for monochrome displays*/
#define USE_LV_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/
#define USE_LV_THEME_ZEN 0 /*Peaceful, mainly light theme */
#define USE_LV_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/
/*==================
* FONT USAGE
@ -261,7 +263,9 @@
/*Button (dependencies: lv_cont*/
#define USE_LV_BTN 1
#if USE_LV_BTN != 0
#define LV_BTN_INK_EFFECT 1 /*1: enable ink effect animation on click. Use `lv_btn_set_ink_in/wait/out_time` to set the animation time*/
#endif
/*Image Button (dependencies: lv_btn*/
#define USE_LV_IMGBTN 1

View File

@ -36,7 +36,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data);
static void indev_proc_press(lv_indev_proc_t * proc);
static void indev_proc_release(lv_indev_proc_t * proc);
static void indev_proc_reset_query_handler(lv_indev_t * indev);
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj);
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj);
static void indev_drag(lv_indev_proc_t * state);
static void indev_drag_throw(lv_indev_proc_t * state);
#endif
@ -587,8 +587,22 @@ static void indev_proc_release(lv_indev_proc_t * proc)
/*Forgot the act obj and send a released signal */
if(proc->act_obj != NULL) {
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
/* If the object was protected against press lost then it possible that
* the object is already not pressed but still it is the `act_obj`.
* In this case send the `LV_SIGNAL_RELEASED` if the indev is ON the `act_obj` */
if(lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST)) {
/* Search the object on the current current coordinates.
* The start object is the object itself. If not ON it the the result will be NULL*/
lv_obj_t * obj_on = indev_search_obj(proc, proc->act_obj);
if(obj_on == proc->act_obj) proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
else proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
}
/* The simple case: `act_obj` was not protected against press lost.
* If it is already not pressed then was handled in `indev_proc_press`*/
else {
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
}
/*Handle click focus*/
#if USE_LV_GROUP
/*Check, if the parent is in a group focus on it.*/
@ -651,21 +665,21 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev)
}
/**
* Search the most top, clickable object on the last point of an input device
* @param indev pointer to an input device
* @param proc pointer to the `lv_indev_proc_t` part of the input device
* @param obj pointer to a start object, typically the screen
* @return pointer to the found object or NULL if there was no suitable object
*/
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj)
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj)
{
lv_obj_t * found_p = NULL;
/*If the point is on this object*/
/*Check its children too*/
if(lv_area_is_point_on(&obj->coords, &indev->act_point)) {
if(lv_area_is_point_on(&obj->coords, &proc->act_point)) {
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
found_p = indev_search_obj(indev, i);
found_p = indev_search_obj(proc, i);
/*If a child was found then break*/
if(found_p != NULL) {

View File

@ -65,22 +65,24 @@ extern "C" {
struct _lv_obj_t;
typedef enum
enum
{
LV_DESIGN_DRAW_MAIN,
LV_DESIGN_DRAW_POST,
LV_DESIGN_COVER_CHK,
} lv_design_mode_t;
};
typedef uint8_t lv_design_mode_t;
typedef bool (* lv_design_func_t) (struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
typedef enum
enum
{
LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action function or an operation was failed*/
LV_RES_OK, /*The object is valid (no deleted) after the action*/
} lv_res_t;
};
typedef uint8_t lv_res_t;
typedef enum
enum
{
/*General signals*/
LV_SIGNAL_CLEANUP,
@ -105,7 +107,8 @@ typedef enum
LV_SIGNAL_DEFOCUS,
LV_SIGNAL_CONTROLL,
LV_SIGNAL_GET_EDITABLE,
} lv_signal_t;
};
typedef uint8_t lv_signal_t;
typedef lv_res_t (* lv_signal_func_t) (struct _lv_obj_t * obj, lv_signal_t sign, void * param);
@ -150,7 +153,7 @@ typedef struct _lv_obj_t
typedef lv_res_t (*lv_action_t) (struct _lv_obj_t * obj);
/*Protect some attributes (max. 8 bit)*/
typedef enum
enum
{
LV_PROTECT_NONE = 0x00,
LV_PROTECT_CHILD_CHG = 0x01, /*Disable the child change signal. Used by the library*/
@ -159,7 +162,8 @@ typedef enum
LV_PROTECT_FOLLOW = 0x08, /*Prevent the object be followed in automatic ordering (e.g. in lv_cont PRETTY layout)*/
LV_PROTECT_PRESS_LOST= 0x10, /*If the `indev` was pressing this object but swiped out while pressing do not search other object.*/
LV_PROTECT_CLICK_FOCUS= 0x20,/*Prevent focusing the object by clicking on it*/
} lv_protect_t;
};
typedef uint8_t lv_protect_t;
/*Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
@ -167,7 +171,7 @@ typedef struct {
const char * type[LV_MAX_ANCESTOR_NUM]; /*[0]: the actual type, [1]: ancestor, [2] #1's ancestor ... [x]: "lv_obj" */
} lv_obj_type_t;
typedef enum
enum
{
LV_ALIGN_CENTER = 0,
LV_ALIGN_IN_TOP_LEFT,
@ -190,9 +194,10 @@ typedef enum
LV_ALIGN_OUT_RIGHT_TOP,
LV_ALIGN_OUT_RIGHT_MID,
LV_ALIGN_OUT_RIGHT_BOTTOM,
} lv_align_t;
};
typedef uint8_t lv_align_t;
typedef enum
enum
{
LV_ANIM_NONE = 0,
LV_ANIM_FLOAT_TOP, /*Float from/to the top*/
@ -201,7 +206,8 @@ typedef enum
LV_ANIM_FLOAT_RIGHT, /*Float from/to the right*/
LV_ANIM_GROW_H, /*Grow/shrink horizontally*/
LV_ANIM_GROW_V, /*Grow/shrink vertically*/
} lv_anim_builtin_t;
};
typedef uint8_t lv_anim_builtin_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -71,6 +71,18 @@ void lv_refr_init(void)
lv_task_ready(task); /*Be sure the screen will be refreshed immediately on start up*/
}
/**
* Redraw the invalidated areas now.
* Normally the redarwing is peridocally executed in `lv_task_handler` but a long blocking process can
* prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar)
* this function can be called when the screen shoud be updated.
*/
void lv_refr_now(void)
{
lv_refr_task(NULL);
}
/**
* Invalidate an area
* @param area_p pointer to area which should be invalidated
@ -322,6 +334,10 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
lv_coord_t row_last = 0;
for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) {
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
/*Calc. the next y coordinates of VDB*/
vdb_p->area.x1 = area_p->x1;
@ -336,6 +352,10 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
/*If the last y coordinates are not handled yet ...*/
if(y2 != row_last) {
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
/*Calc. the next y coordinates of VDB*/
vdb_p->area.x1 = area_p->x1;
@ -355,6 +375,10 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
static void lv_refr_area_part_vdb(const lv_area_t * area_p)
{
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
lv_obj_t * top_p;
/*Get the new mask from the original area and the act. VDB

View File

@ -45,6 +45,14 @@ extern "C" {
*/
void lv_refr_init(void);
/**
* Redraw the invalidated areas now.
* Normally the redarwing is peridocally executed in `lv_task_handler` but a long blocking process can
* prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar)
* this function can be called when the screen shoud be updated.
*/
void lv_refr_now(void);
/**
* Invalidate an area
* @param area_p pointer to area which should be invalidated

View File

@ -75,7 +75,6 @@ void lv_style_init(void)
/*Screen style*/
lv_style_scr.glass = 0;
lv_style_scr.body.opa = LV_OPA_COVER;
lv_style_scr.body.thickness = LV_DPI / 12;
lv_style_scr.body.main_color = LV_COLOR_WHITE;
lv_style_scr.body.grad_color = LV_COLOR_WHITE;
lv_style_scr.body.radius = 0;
@ -104,7 +103,8 @@ void lv_style_init(void)
lv_style_scr.line.opa = LV_OPA_COVER;
lv_style_scr.line.color = LV_COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_scr.line.width = 1;
lv_style_scr.line.width = 2;
lv_style_scr.line.rounded = 0;
/*Plain style (by default near the same as the screen style)*/
memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t));
@ -256,12 +256,14 @@ void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t *
res->glass = start->glass;
res->text.font = start->text.font;
res->body.shadow.type = start->body.shadow.type;
res->line.rounded = start->line.rounded;
} else {
res->body.empty = end->body.empty;
res->body.border.part = end->body.border.part;
res->glass = end->glass;
res->text.font = end->text.font;
res->body.shadow.type = end->body.shadow.type;
res->line.rounded = end->line.rounded;
}
}

View File

@ -29,7 +29,7 @@ extern "C" {
**********************/
/*Border types (Use 'OR'ed values)*/
typedef enum
enum
{
LV_BORDER_NONE = 0x00,
LV_BORDER_BOTTOM = 0x01,
@ -37,14 +37,16 @@ typedef enum
LV_BORDER_LEFT = 0x04,
LV_BORDER_RIGHT = 0x08,
LV_BORDER_FULL = 0x0F,
} lv_border_part_t;
};
typedef uint8_t lv_border_part_t;
/*Shadow types*/
typedef enum
enum
{
LV_SHADOW_BOTTOM = 0,
LV_SHADOW_FULL,
} lv_shadow_type_t;
};
typedef uint8_t lv_shadow_type_t;
typedef struct
{
@ -52,12 +54,8 @@ typedef struct
struct {
lv_color_t main_color;
union {
lv_color_t grad_color; /*`grad_color` will be removed in v6.0, use `aux_color` instead*/
lv_color_t aux_color;
};
lv_color_t grad_color; /*`grad_color` will be removed in v6.0, use `aux_color` instead*/
lv_coord_t radius;
lv_coord_t thickness; /*Depending on the object type thickness of something*/
lv_opa_t opa;
struct {
@ -70,7 +68,7 @@ typedef struct
struct {
lv_color_t color;
lv_coord_t width;
uint8_t type;
lv_shadow_type_t type;
} shadow;
struct {
@ -101,6 +99,7 @@ typedef struct
lv_color_t color;
lv_coord_t width;
lv_opa_t opa;
uint8_t rounded :1; /*1: rounded line endings*/
} line;
} lv_style_t;

View File

@ -10,6 +10,7 @@
#if LV_VDB_SIZE != 0
#include "../lv_hal/lv_hal_disp.h"
#include "../lv_misc/lv_log.h"
#include <stddef.h>
/*********************
@ -19,11 +20,12 @@
/**********************
* TYPEDEFS
**********************/
typedef enum {
enum {
LV_VDB_STATE_FREE = 0, /*Not used*/
LV_VDB_STATE_ACTIVE, /*Being used to render*/
LV_VDB_STATE_FLUSH, /*Flushing pixels from it*/
} lv_vdb_state_t;
};
typedef uint8_t lv_vdb_state_t;
/**********************
* STATIC PROTOTYPES
@ -38,7 +40,7 @@ typedef enum {
static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE;
# if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf[(LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3];
static uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES];
static lv_vdb_t vdb = {.buf = (lv_color_t*)vdb_buf};
# else /*LV_VDB_ADR != 0*/
/*If the buffer address is specified use that address*/
@ -49,8 +51,8 @@ static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
# if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf1[(LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3];
static uint8_t vdb_buf2[(LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3];
static uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
static uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES];
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *) vdb_buf1}, {.buf = (lv_color_t *) vdb_buf2}};
# else /*LV_VDB_ADR != 0*/
/*If the buffer address is specified use that address*/
@ -76,6 +78,11 @@ lv_vdb_t * lv_vdb_get(void)
/* Wait until VDB become ACTIVE from FLUSH by the
* user call of 'lv_flush_ready()' in display drivers's flush function*/
while(vdb_state != LV_VDB_STATE_ACTIVE);
if(vdb.buf == (void*)LV_VDB_ADR_INV) {
LV_LOG_ERROR("VDB address is invalid. Use `lv_vdb_set_adr` to set a valid address or use LV_VDB_ADR = 0 in lv_conf.h");
return NULL;
}
return &vdb;
#else
/*If already there is an active do nothing*/
@ -103,8 +110,10 @@ lv_vdb_t * lv_vdb_get(void)
void lv_vdb_flush(void)
{
lv_vdb_t * vdb_act = lv_vdb_get();
if(vdb_act == NULL) return;
if(!vdb_act) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
#if LV_VDB_DOUBLE == 0
vdb_state = LV_VDB_STATE_FLUSH; /*User call to 'lv_flush_ready()' will set to ACTIVE 'disp_flush'*/
#else
@ -122,6 +131,23 @@ void lv_vdb_flush(void)
}
/**
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
* It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES`
* @param buf1 address of the VDB.
* @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0`
*/
void lv_vdb_set_adr(void * buf1, void * buf2)
{
#if LV_VDB_DOUBLE == 0
vdb.buf = buf1;
#else
vdb[0].buf = buf1;
vdb[1].buf = buf2;
#endif
}
/**
* Call in the display driver's 'disp_flush' function when the flushing is finished
*/
@ -129,9 +155,24 @@ void lv_flush_ready(void)
{
#if LV_VDB_DOUBLE == 0
vdb_state = LV_VDB_STATE_ACTIVE;
#if LV_COLOR_SCREEN_TRANSP
memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES);
#endif
#else
if(vdb_state[0] == LV_VDB_STATE_FLUSH) vdb_state[0] = LV_VDB_STATE_FREE;
if(vdb_state[1] == LV_VDB_STATE_FLUSH) vdb_state[1] = LV_VDB_STATE_FREE;
if(vdb_state[0] == LV_VDB_STATE_FLUSH) {
#if LV_COLOR_SCREEN_TRANSP
memset(vdb_buf[0], 0x00, LV_VDB_SIZE_IN_BYTES);
#endif
vdb_state[0] = LV_VDB_STATE_FREE;
}
if(vdb_state[1] == LV_VDB_STATE_FLUSH) {
#if LV_COLOR_SCREEN_TRANSP
memset(vdb_buf[1], 0x00, LV_VDB_SIZE_IN_BYTES);
#endif
vdb_state[1] = LV_VDB_STATE_FREE;
}
#endif
}

View File

@ -27,11 +27,20 @@ extern "C" {
/*********************
* DEFINES
*********************/
/*Can be used in `lv_conf.h` the set an invalid address for the VDB. It should be replaced later by a valid address using `lv_vdb_set_adr()`*/
#define LV_VDB_ADR_INV 8 /*8 is still too small to be valid but it's aligned on 64 bit machines as well*/
#ifndef LV_VDB_PX_BPP
#warning "LV_VDB_PX_BPP is not specified in lv_conf.h. Use the default value (LV_COLOR_SIZE)"
#define LV_VDB_PX_BPP LV_COLOR_SIZE
#endif
/* The size of VDB in bytes.
* (LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3): just divide by 8 to convert bits to bytes
* (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0): add an extra byte to round up.
* E.g. if LV_VDB_SIZE = 10 and LV_VDB_PX_BPP = 1 -> 10 bits -> 2 bytes*/
#define LV_VDB_SIZE_IN_BYTES ((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)
/**********************
* TYPEDEFS
**********************/
@ -57,6 +66,14 @@ lv_vdb_t * lv_vdb_get(void);
*/
void lv_vdb_flush(void);
/**
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
* It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES`
* @param buf1 address of the VDB.
* @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0`
*/
void lv_vdb_set_adr(void * buf1, void * buf2);
/**
* Call in the display driver's 'disp_flush' function when the flushing is finished
*/

View File

@ -30,7 +30,7 @@ extern "C" {
# define LV_IMG_PX_SIZE_ALPHA_BYTE 2
#elif LV_COLOR_DEPTH == 16
# define LV_IMG_PX_SIZE_ALPHA_BYTE 3
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
# define LV_IMG_PX_SIZE_ALPHA_BYTE 4
#endif
@ -38,12 +38,13 @@ extern "C" {
* TYPEDEFS
**********************/
typedef enum {
enum {
LV_IMG_SRC_VARIABLE,
LV_IMG_SRC_FILE,
LV_IMG_SRC_SYMBOL,
LV_IMG_SRC_UNKNOWN,
} lv_img_src_t;
};
typedef uint8_t lv_img_src_t;
/**********************

View File

@ -52,7 +52,7 @@ static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end);
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale)
{
lv_coord_t thickness = style->body.thickness;
lv_coord_t thickness = style->line.width;
if(thickness > radius) thickness = radius;
lv_coord_t r_out = radius;
@ -62,7 +62,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons
lv_coord_t x_start[4];
lv_coord_t x_end[4];
lv_color_t color = style->body.main_color;
lv_color_t color = style->line.color;
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;

View File

@ -21,7 +21,7 @@
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * style);
static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
@ -38,7 +38,7 @@ static lv_img_src_t decoder_src_type;
static lv_img_header_t decoder_header;
static const lv_style_t * decoder_style;
static lv_fs_file_t decoder_file;
static lv_color_t decoder_index_map[256] = {LV_COLOR_RED, LV_COLOR_BLUE, LV_COLOR_GREEN, LV_COLOR_PURPLE};
static lv_color_t decoder_index_map[256] = {{{0}}};
static lv_img_decoder_info_f_t lv_img_decoder_info_custom;
static lv_img_decoder_open_f_t lv_img_decoder_open_custom;
@ -102,8 +102,7 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
lv_img_src_t src_type = lv_img_src_get_type(src);
if(src_type == LV_IMG_SRC_VARIABLE) {
header->cf =
header->w = ((lv_img_dsc_t *)src)->header.w;
header->w = ((lv_img_dsc_t *)src)->header.w;
header->h = ((lv_img_dsc_t *)src)->header.h;
header->cf = ((lv_img_dsc_t *)src)->header.cf;
}
@ -144,75 +143,72 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_UNKOWN:
case LV_IMG_CF_RAW:
return 0;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_COLOR_SIZE;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
#if LV_COLOR_DEPTH != 24
return LV_COLOR_SIZE;
#else
return LV_COLOR_SIZE + 1;
#endif
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT:
return 1;
switch(cf) {
case LV_IMG_CF_UNKOWN:
case LV_IMG_CF_RAW:
return 0;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_COLOR_SIZE;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
return LV_IMG_PX_SIZE_ALPHA_BYTE;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT:
return 2;
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT:
return 1;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT:
return 4;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT:
return 2;
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT:
return 8;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT:
return 4;
default:
return 0;
}
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT:
return 8;
return 0;
default:
return 0;
}
return 0;
}
bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
case LV_IMG_CF_RAW_CHROMA_KEYED:
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
return true;
default:
return false;
}
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
return true;
default:
return false;
}
return false;
return false;
}
bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
{
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA:
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA:
case LV_IMG_CF_RAW_ALPHA:
case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT:
return true;
default:
return false;
}
case LV_IMG_CF_ALPHA_1BIT:
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT:
return true;
default:
return false;
}
return false;
return false;
}
/**
@ -231,11 +227,9 @@ lv_img_src_t lv_img_src_get_type(const void * src)
/*The first byte shows the type of the image source*/
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
return LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
}
else if(u8_p[0] >= 0x80) {
} else if(u8_p[0] >= 0x80) {
return LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
}
else {
} else {
return LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
}
@ -250,11 +244,11 @@ lv_img_src_t lv_img_src_get_type(const void * src)
* @param close_fp clode function
*/
void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_open_f_t open_fp,
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp)
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp)
{
lv_img_decoder_info_custom = info_fp;
lv_img_decoder_open_custom = open_fp;
lv_img_decoder_read_line_custom= read_fp;
lv_img_decoder_read_line_custom = read_fp;
lv_img_decoder_close_custom = close_fp;
}
@ -265,7 +259,7 @@ void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
{
lv_area_t mask_com; /*Common area of mask and coords*/
@ -387,8 +381,7 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
lv_img_cf_t cf = decoder_header.cf;
if(cf == LV_IMG_CF_TRUE_COLOR ||
cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
{
cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
/*In case of uncompressed formats if the image stored in the ROM/RAM simply give it's pointer*/
return ((lv_img_dsc_t *)decoder_src)->data;
@ -396,27 +389,25 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
/*If it's file it need to be read line by line later*/
return NULL;
}
}
else if (cf == LV_IMG_CF_INDEXED_1BIT ||
cf == LV_IMG_CF_INDEXED_2BIT ||
cf == LV_IMG_CF_INDEXED_4BIT ||
cf == LV_IMG_CF_INDEXED_8BIT)
{
lv_color24_t palette_file[256];
lv_color24_t * palette_p = NULL;
} else if(cf == LV_IMG_CF_INDEXED_1BIT ||
cf == LV_IMG_CF_INDEXED_2BIT ||
cf == LV_IMG_CF_INDEXED_4BIT ||
cf == LV_IMG_CF_INDEXED_8BIT) {
lv_color32_t palette_file[256];
lv_color32_t * palette_p = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(cf);
uint32_t palette_size = 1 << px_size;
if(decoder_src_type == LV_IMG_SRC_FILE) {
#if USE_LV_FILESYSTEM
lv_fs_seek(&decoder_file, 4); /*Skip the header*/
lv_fs_read(&decoder_file, palette_file, palette_size * sizeof(lv_color24_t), NULL);
lv_fs_read(&decoder_file, palette_file, palette_size * sizeof(lv_color32_t), NULL);
palette_p = palette_file;
#else
palette_file[0] = 0; /*Just to solve warnings*/
#endif
} else {
palette_p = (lv_color_t*)((lv_img_dsc_t *)decoder_src)->data;
palette_p = (lv_color_t *)((lv_img_dsc_t *)decoder_src)->data;
}
uint32_t i;
@ -424,16 +415,12 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
decoder_index_map[i] = LV_COLOR_MAKE(palette_p[i].red, palette_p[i].green, palette_p[i].blue);
}
return NULL;
}
else if (cf == LV_IMG_CF_ALPHA_1BIT ||
cf == LV_IMG_CF_ALPHA_2BIT ||
cf == LV_IMG_CF_ALPHA_4BIT ||
cf == LV_IMG_CF_ALPHA_8BIT)
{
} else if(cf == LV_IMG_CF_ALPHA_1BIT ||
cf == LV_IMG_CF_ALPHA_2BIT ||
cf == LV_IMG_CF_ALPHA_4BIT ||
cf == LV_IMG_CF_ALPHA_8BIT) {
return NULL; /*Nothing to process*/
}
else
{
} else {
LV_LOG_WARN("Image decoder open: unknown color format")
return LV_IMG_DECODER_OPEN_FAIL;
}
@ -461,9 +448,8 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
lv_fs_res_t res;
if(decoder_header.cf == LV_IMG_CF_TRUE_COLOR ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
{
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
uint32_t pos = ((y * decoder_header.w + x) * px_size) >> 3;
res = lv_fs_seek(&decoder_file, pos);
if(res != LV_FS_RES_OK) {
@ -477,18 +463,15 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
LV_LOG_WARN("Built-in image decoder read failed");
return false;
}
}
else if(decoder_header.cf == LV_IMG_CF_ALPHA_1BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_2BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_4BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT)
{
} else if(decoder_header.cf == LV_IMG_CF_ALPHA_1BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_2BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_4BIT ||
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT) {
lv_img_built_in_decoder_line_alpha(x, y, len, buf);
} else if(decoder_header.cf == LV_IMG_CF_INDEXED_1BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_2BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_4BIT ||
decoder_header.cf == LV_IMG_CF_INDEXED_8BIT)
{
decoder_header.cf == LV_IMG_CF_INDEXED_8BIT) {
lv_img_built_in_decoder_line_indexed(x, y, len, buf);
} else {
LV_LOG_WARN("Built-in image decoder read not supports the color format");
@ -498,20 +481,18 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
LV_LOG_WARN("Image built-in decoder can't read file because USE_LV_FILESYSTEM = 0");
return false;
#endif
} else if (decoder_src_type == LV_IMG_SRC_VARIABLE) {
} else if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
const lv_img_dsc_t * img_dsc = decoder_src;
if(img_dsc->header.cf == LV_IMG_CF_ALPHA_1BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_4BIT ||
img_dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)
{
img_dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
lv_img_built_in_decoder_line_alpha(x, y, len, buf);
} else if(img_dsc->header.cf == LV_IMG_CF_INDEXED_1BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_4BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_8BIT)
{
img_dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_4BIT ||
img_dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
lv_img_built_in_decoder_line_indexed(x, y, len, buf);
} else {
LV_LOG_WARN("Built-in image decoder not supports the color format");
@ -546,9 +527,9 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
/*Simply fill the buffer with the color. Later only the alpha value will be modified.*/
@ -561,55 +542,55 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
/*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE] = bg_color.full & 0xFF;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + 1] = (bg_color.full >> 8) & 0xFF;
#elif LV_COLOR_DEPTH == 24
*((uint32_t*)&buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE]) = bg_color.full;
#elif LV_COLOR_DEPTH == 32
*((uint32_t *)&buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE]) = bg_color.full;
#endif
}
const lv_opa_t * opa_table = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(decoder_header.cf);
uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/
const lv_opa_t * opa_table = NULL;
uint8_t px_size = lv_img_color_format_get_px_size(decoder_header.cf);
uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/
lv_coord_t w = 0;
uint32_t ofs = 0;
int8_t pos = 0;
switch(decoder_header.cf) {
case LV_IMG_CF_ALPHA_1BIT:
w = (decoder_header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(decoder_header.w & 0x7) w++;
ofs += w * y + (x >> 3); /*First pixel*/
pos = 7 - (x & 0x7);
opa_table = alpha1_opa_table;
break;
lv_coord_t w = 0;
uint32_t ofs = 0;
int8_t pos = 0;
switch(decoder_header.cf) {
case LV_IMG_CF_ALPHA_1BIT:
w = (decoder_header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(decoder_header.w & 0x7) w++;
ofs += w * y + (x >> 3); /*First pixel*/
pos = 7 - (x & 0x7);
opa_table = alpha1_opa_table;
break;
case LV_IMG_CF_ALPHA_2BIT:
w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(decoder_header.w & 0x3) w++;
ofs += w * y + (x >> 2); /*First pixel*/
pos = 6 - ((x & 0x3) * 2);
opa_table = alpha2_opa_table;
break;
break;
case LV_IMG_CF_ALPHA_4BIT:
w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(decoder_header.w & 0x1) w++;
ofs += w * y + (x >> 1); /*First pixel*/
pos = 4 - ((x & 0x1) * 4);
opa_table = alpha4_opa_table;
break;
break;
case LV_IMG_CF_ALPHA_8BIT:
w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
ofs += w * y + x; /*First pixel*/
pos = 0;
break;
}
break;
}
#if USE_LV_FILESYSTEM
# if LV_COMPILER_VLA_SUPPORTED
uint8_t fs_buf[w];
uint8_t fs_buf[w];
# else
# if LV_HOR_RES > LV_VER_RES
uint8_t fs_buf[LV_HOR_RES];
uint8_t fs_buf[LV_HOR_RES];
# else
uint8_t fs_buf[LV_VER_RES];
uint8_t fs_buf[LV_VER_RES];
# endif
# endif
#endif
@ -630,22 +611,22 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
}
uint8_t byte_act = 0;
uint8_t val_act;
for(i = 0; i < len; i ++) {
val_act = (data_tmp[byte_act] & (mask << pos)) >> pos;
uint8_t byte_act = 0;
uint8_t val_act;
for(i = 0; i < len; i ++) {
val_act = (data_tmp[byte_act] & (mask << pos)) >> pos;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] =
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act];
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] =
decoder_header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act];
pos -= px_size;
if(pos < 0) {
pos = 8 - px_size;
data_tmp++;
}
}
pos -= px_size;
if(pos < 0) {
pos = 8 - px_size;
data_tmp++;
}
}
return LV_RES_OK;
return LV_RES_OK;
}
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf)
@ -664,37 +645,37 @@ static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y,
ofs += w * y + (x >> 3); /*First pixel*/
ofs += 8; /*Skip the palette*/
pos = 7 - (x & 0x7);
break;
break;
case LV_IMG_CF_INDEXED_2BIT:
w = (decoder_header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(decoder_header.w & 0x3) w++;
ofs += w * y + (x >> 2); /*First pixel*/
ofs += 16; /*Skip the palette*/
pos = 6 - ((x & 0x3) * 2);
break;
break;
case LV_IMG_CF_INDEXED_4BIT:
w = (decoder_header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(decoder_header.w & 0x1) w++;
ofs += w * y + (x >> 1); /*First pixel*/
ofs += 64; /*Skip the palette*/
pos = 4 - ((x & 0x1) * 4);
break;
break;
case LV_IMG_CF_INDEXED_8BIT:
w = decoder_header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
ofs += w * y + x; /*First pixel*/
ofs += 1024; /*Skip the palette*/
pos = 0;
break;
break;
}
#if USE_LV_FILESYSTEM
# if LV_COMPILER_VLA_SUPPORTED
uint8_t fs_buf[w];
uint8_t fs_buf[w];
# else
# if LV_HOR_RES > LV_VER_RES
uint8_t fs_buf[LV_HOR_RES];
uint8_t fs_buf[LV_HOR_RES];
# else
uint8_t fs_buf[LV_VER_RES];
uint8_t fs_buf[LV_VER_RES];
# endif
# endif
#endif

View File

@ -40,7 +40,7 @@ typedef struct {
}lv_img_header_t;
/*Image color format*/
typedef enum {
enum {
LV_IMG_CF_UNKOWN = 0,
LV_IMG_CF_RAW, /*Contains the file as it is. Needs custom decoder function*/
@ -60,7 +60,8 @@ typedef enum {
LV_IMG_CF_ALPHA_2BIT, /*Can have one color but 4 different alpha value*/
LV_IMG_CF_ALPHA_4BIT, /*Can have one color but 16 different alpha value*/
LV_IMG_CF_ALPHA_8BIT, /*Can have one color but 256 different alpha value*/
} lv_img_cf_t;
};
typedef uint8_t lv_img_cf_t;
/* Image header it is compatible with
* the result image converter utility*/

View File

@ -17,11 +17,12 @@
/**********************
* TYPEDEFS
**********************/
typedef enum {
enum {
CMD_STATE_WAIT,
CMD_STATE_PAR,
CMD_STATE_IN,
} cmd_state_t;
};
typedef uint8_t cmd_state_t;
/**********************
* STATIC PROTOTYPES

View File

@ -184,15 +184,10 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
{
lv_coord_t width;
width = style->line.width;
lv_coord_t width_safe = width;
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
#if LV_ANTIALIAS
width--;
if(width == 0) width_safe = 1;
else width_safe = width;
lv_coord_t width_safe = width; /*`width_safe` is always >=1*/
#endif
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
lv_point_t vect_main, vect_norm;
vect_main.x = main_line->p2.x - main_line->p1.x;
@ -234,10 +229,23 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
lv_point_t p0 = {0, 0};
line_init(&pattern_line, &p0, &vect_norm);
for(i = 0; i < width; i ++) {
uint32_t width_sqr = width * width;
for(i = 0; i < width * 2; i ++) { /*Run until a big number. Meanwhile the real width will be determined as well*/
pattern[i].x = pattern_line.p_act.x;
pattern[i].y = pattern_line.p_act.y;
/*Finish the pattern line if it's length equal to the desired width (Use Pythagoras theorem)*/
int32_t sqr = pattern_line.p_act.x * pattern_line.p_act.x + pattern_line.p_act.y * pattern_line.p_act.y;
if(sqr >= width_sqr) {
width = i;
#if LV_ANTIALIAS
width--;
if(width == 0) width_safe = 1;
else width_safe = width;
#endif
break;
}
line_next(&pattern_line);
}
} else {

View File

@ -1123,7 +1123,7 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
uint16_t col;
#if LV_COMPILER_VLA_SUPPORTED
lv_opa_t line_2d_blur[radius + swidth];
lv_opa_t line_2d_blur[radius + swidth + 1];
#else
# if LV_HOR_RES > LV_VER_RES
lv_opa_t line_2d_blur[LV_HOR_RES];

View File

@ -40,6 +40,10 @@
static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa);
#if LV_COLOR_SCREEN_TRANSP
static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa);
#endif
/**********************
* STATIC VARIABLES
**********************/
@ -62,10 +66,14 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
*/
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
/*Pixel out of the mask*/
if(x < mask_p->x1 || x > mask_p->x2 ||
@ -81,14 +89,18 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
lv_disp_t * disp = lv_disp_get_active();
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, x, y, color, opa);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa);
} else {
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
if(opa == LV_OPA_COVER) {
*vdb_px_p = color;
} else {
*vdb_px_p = lv_color_mix(color, *vdb_px_p, opa);
}
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
#if LV_COLOR_SCREEN_TRANSP == 0
if(opa == LV_OPA_COVER) {
*vdb_px_p = color;
} else {
*vdb_px_p = lv_color_mix(color, *vdb_px_p, opa);
}
#else
*vdb_px_p = color_mix_2_alpha(*vdb_px_p, (*vdb_px_p).alpha, color, opa);
#endif
}
}
@ -103,12 +115,16 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t color, lv_opa_t opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_area_t res_a;
bool union_ok;
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
/*Get the union of cord and mask*/
/* The mask is already truncated to the vdb size
@ -221,16 +237,16 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
const uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255
};
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(font_p == NULL) {
LV_LOG_WARN("Font: character's bitmap not found");
return;
LV_LOG_WARN("Font: character's bitmap not found");
return;
}
lv_coord_t pos_x = pos_p->x;
@ -238,12 +254,12 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
uint8_t letter_w = lv_font_get_real_width(font_p, letter);
uint8_t letter_h = lv_font_get_height(font_p);
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
uint8_t * bpp_opa_table;
const uint8_t * bpp_opa_table;
uint8_t mask_init;
uint8_t mask;
if(lv_font_is_monospace(font_p, letter)) {
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
}
@ -277,6 +293,11 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
pos_y + letter_h < mask_p->y1 || pos_y > mask_p->y2) return;
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area);
lv_color_t * vdb_buf_tmp = vdb_p->buf;
lv_coord_t col, row;
@ -314,21 +335,25 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
for(col = col_start; col < col_end; col ++) {
letter_px = (*map_p & mask) >> (8 - col_bit - bpp);
if(letter_px != 0) {
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
px_opa = bpp == 8 ?
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
}
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
px_opa = bpp == 8 ?
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
}
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width,
(col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1,
color, px_opa);
} else {
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa);
}
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width,
(col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1,
color, px_opa);
} else {
#if LV_COLOR_SCREEN_TRANSP == 0
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa);
#else
*vdb_buf_tmp = color_mix_2_alpha(*vdb_buf_tmp, (*vdb_buf_tmp).alpha, color, px_opa);
#endif
}
}
vdb_buf_tmp++;
@ -365,12 +390,16 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t recolor, lv_opa_t recolor_opa)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_area_t masked_a;
bool union_ok;
lv_vdb_t * vdb_p = lv_vdb_get();
if(!vdb_p) {
LV_LOG_WARN("Invalid VDB pointer");
return;
}
/*Get the union of map size and mask*/
/* The mask is already truncated to the vdb size
@ -411,33 +440,33 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*The simplest case just copy the pixels into the VDB*/
if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) {
/*Use the custom VDB write function is exists*/
if(disp->driver.vdb_wr) {
lv_coord_t col;
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = (lv_color_t) *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
}
map_p += map_width * px_size_byte; /*Next row on the map*/
}
}
/*Normal native VDB*/
else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
/*Use the custom VDB write function is exists*/
if(disp->driver.vdb_wr) {
lv_coord_t col;
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = (lv_color_t) * ((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
}
map_p += map_width * px_size_byte; /*Next row on the map*/
}
}
/*Normal native VDB*/
else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
#if USE_LV_GPU
if(lv_disp_is_mem_blend_supported() == false) {
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
} else {
lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
}
if(lv_disp_is_mem_blend_supported() == false) {
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
} else {
lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
}
#else
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
#endif
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
}
/*In the other cases every pixel need to be checked one-by-one*/
@ -459,7 +488,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
#elif LV_COLOR_DEPTH == 16
/*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/
px_color.full = px_color_p[0] + (px_color_p[1] << 8);
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
px_color = *((lv_color_t *)px_color_p);
#endif
lv_opa_t px_opa = *(px_color_p + LV_IMG_PX_SIZE_ALPHA_BYTE - 1);
@ -480,28 +509,49 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
}
/*Handle custom VDB write is present*/
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
}
/*Normal native VDB write*/
else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
}
} else {
/*Handle custom VDB write is present*/
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t*)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result);
}
/*Normal native VDB write*/
else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
else vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
}
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result);
}
/*Normal native VDB write*/
else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
else {
#if LV_COLOR_SCREEN_TRANSP == 0
vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
#else
vdb_buf_tmp[col] = color_mix_2_alpha(vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result);
// if(vdb_buf_tmp[col].alpha == LV_OPA_TRANSP) {
// /* When it is the first visible pixel on the transparent screen
// * simlply use this color and set the pixel opa as backrounds alpha*/
// vdb_buf_tmp[col] = px_color;
// vdb_buf_tmp[col].alpha = opa_result;
// } else {
// /* If already this pixel is already written then for performance reasons
// * don't care with alpha channel
// */
// lv_opa_t bg_opa = vdb_buf_tmp[col].alpha;
// vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
//
// uint16_t opa_tmp = (uint16_t)opa_result + ((bg_opa * (255 - opa_result)) >> 8);
// vdb_buf_tmp[col].alpha = opa_tmp > 0xFF ? 0xFF : opa_tmp ;
// }
#endif
}
}
}
}
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
map_p += map_width * px_size_byte; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
}
@ -546,49 +596,108 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
lv_disp_t * disp = lv_disp_get_active();
if(disp->driver.vdb_wr) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
for(row = fill_area->y1; row <= fill_area->y2; row++) {
disp->driver.vdb_wr((uint8_t*)mem, mem_width, col, row, color, opa);
}
}
for(col = fill_area->x1; col <= fill_area->x2; col++) {
for(row = fill_area->y1; row <= fill_area->y2; row++) {
disp->driver.vdb_wr((uint8_t *)mem, mem_width, col, row, color, opa);
}
}
} else {
mem += fill_area->y1 * mem_width; /*Go to the first row*/
mem += fill_area->y1 * mem_width; /*Go to the first row*/
/*Run simpler function without opacity*/
if(opa == LV_OPA_COVER) {
/*Run simpler function without opacity*/
if(opa == LV_OPA_COVER) {
/*Fill the first row with 'color'*/
for(col = fill_area->x1; col <= fill_area->x2; col++) {
mem[col] = color;
}
/*Fill the first row with 'color'*/
for(col = fill_area->x1; col <= fill_area->x2; col++) {
mem[col] = color;
}
/*Copy the first row to all other rows*/
lv_color_t * mem_first = &mem[fill_area->x1];
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
mem += mem_width;
/*Copy the first row to all other rows*/
lv_color_t * mem_first = &mem[fill_area->x1];
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
mem += mem_width;
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
memcpy(&mem[fill_area->x1], mem_first, copy_size);
mem += mem_width;
}
}
/*Calculate with alpha too*/
else {
lv_color_t bg_tmp = LV_COLOR_BLACK;
lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa);
for(row = fill_area->y1; row <= fill_area->y2; row++) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
/*If the bg color changed recalculate the result color*/
if(mem[col].full != bg_tmp.full) {
bg_tmp = mem[col];
opa_tmp = lv_color_mix(color, bg_tmp, opa);
}
mem[col] = opa_tmp;
}
mem += mem_width;
}
}
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
memcpy(&mem[fill_area->x1], mem_first, copy_size);
mem += mem_width;
}
}
/*Calculate with alpha too*/
else {
#if LV_COLOR_SCREEN_TRANSP == 0
lv_color_t bg_tmp = LV_COLOR_BLACK;
lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa);
#endif
for(row = fill_area->y1; row <= fill_area->y2; row++) {
for(col = fill_area->x1; col <= fill_area->x2; col++) {
#if LV_COLOR_SCREEN_TRANSP == 0
/*If the bg color changed recalculate the result color*/
if(mem[col].full != bg_tmp.full) {
bg_tmp = mem[col];
opa_tmp = lv_color_mix(color, bg_tmp, opa);
}
mem[col] = opa_tmp;
#else
mem[col] = color_mix_2_alpha(mem[col], mem[col].alpha, color, opa);
#endif
}
mem += mem_width;
}
}
}
}
#if LV_COLOR_SCREEN_TRANSP
/**
* Mix two colors. Both color can have alpha value. It requires ARGB888 colors.
* @param bg_color background color
* @param bg_opa alpha of the background color
* @param fg_color foreground color
* @param fg_opa alpha of the foreground color
* @return the mixed color. the alpha channel (color.alpha) contains the result alpha
*/
static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa)
{
/* Pick the foreground if it's fully opaque or the Background is fully transparent*/
if(fg_opa == LV_OPA_COVER && bg_opa <= LV_OPA_MIN) {
fg_color.alpha = fg_opa;
return fg_color;
}
/*Transparent foreground: use the Background*/
else if(fg_opa <= LV_OPA_MIN) {
return bg_color;
}
/*Opaque background: use simple mix*/
else if (bg_opa >= LV_OPA_MAX) {
return lv_color_mix(fg_color, bg_color, fg_opa);
}
/*Both colors have alpha. Expensive calculation need to be applied*/
else {
/*Save the parameters and the result. If they will be asked again don't compute again*/
static lv_opa_t fg_opa_save = 0;
static lv_opa_t bg_opa_save = 0;
static lv_color_t c = {0};
if(fg_opa != fg_opa_save || bg_opa != bg_opa_save) {
fg_opa_save = fg_opa;
bg_opa_save = bg_opa;
/*Info: https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator*/
lv_opa_t alpha_res = 255 - ((uint16_t)((uint16_t)(255 - fg_opa) * (255 - bg_opa)) >> 8);
if(alpha_res == 0) {
while(1);
}
lv_opa_t ratio = (uint16_t)((uint16_t) fg_opa * 255) / alpha_res;
c = lv_color_mix(fg_color, bg_color, ratio);
c.alpha = alpha_res;
}
return c;
}
}
#endif /*LV_COLOR_SCREEN_TRANSP*/
#endif

View File

@ -29,18 +29,20 @@ extern "C" {
**********************/
/*Possible input device types*/
typedef enum {
enum {
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
LV_INDEV_TYPE_POINTER, /*Touch pad, mouse, external button*/
LV_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/
LV_INDEV_TYPE_BUTTON, /*External (hardware button) which is assinged to a specific point of the screen*/
} lv_hal_indev_type_t;
};
typedef uint8_t lv_hal_indev_type_t;
/*States for input devices*/
typedef enum {
enum {
LV_INDEV_STATE_REL = 0,
LV_INDEV_STATE_PR
} lv_indev_state_t;
};
typedef uint8_t lv_indev_state_t;
/*Data type when an input device is read */
typedef struct {
@ -49,8 +51,8 @@ typedef struct {
uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
uint32_t btn; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/
};
lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/
void *user_data; /*'lv_indev_drv_t.priv' for this driver*/
lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/
} lv_indev_data_t;
/*Initialized by the user and registered by 'lv_indev_add()'*/

View File

@ -73,6 +73,7 @@ a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
lv_anim_create(&a);
*/
/**********************
* GLOBAL PROTOTYPES

View File

@ -19,28 +19,40 @@ extern "C" {
#include "../../lv_conf.h"
#endif
/*Error checking*/
#if LV_COLOR_DEPTH != 32 && LV_COLOR_SCREEN_TRANSP != 0
#error "LV_COLOR_SCREEN_TRANSP requires LV_COLOR_DEPTH == 32. Set it in lv_conf.h"
#endif
#if LV_COLOR_DEPTH != 16 && LV_COLOR_16_SWAP != 0
#error "LV_COLOR_16_SWAP requires LV_COLOR_DEPTH == 16. Set it in lv_conf.h"
#endif
#include <stdint.h>
/*********************
* DEFINES
*********************/
#define LV_COLOR_BLACK LV_COLOR_MAKE(0x00,0x00,0x00)
#define LV_COLOR_WHITE LV_COLOR_MAKE(0xFF,0xFF,0xFF)
#define LV_COLOR_RED LV_COLOR_MAKE(0xFF,0x00,0x00)
#define LV_COLOR_LIME LV_COLOR_MAKE(0x00,0xFF,0x00)
#define LV_COLOR_BLUE LV_COLOR_MAKE(0x00,0x00,0xFF)
#define LV_COLOR_YELLOW LV_COLOR_MAKE(0xFF,0xFF,0x00)
#define LV_COLOR_CYAN LV_COLOR_MAKE(0x00,0xFF,0xFF)
#define LV_COLOR_AQUA LV_COLOR_CYAN
#define LV_COLOR_MAGENTA LV_COLOR_MAKE(0xFF,0x00,0xFF)
#define LV_COLOR_SILVER LV_COLOR_MAKE(0xC0,0xC0,0xC0)
#define LV_COLOR_GRAY LV_COLOR_MAKE(0x80,0x80,0x80)
#define LV_COLOR_MARRON LV_COLOR_MAKE(0x80,0x00,0x00)
#define LV_COLOR_BLACK LV_COLOR_MAKE(0x00,0x00,0x00)
#define LV_COLOR_RED LV_COLOR_MAKE(0xFF,0x00,0x00)
#define LV_COLOR_MAROON LV_COLOR_MAKE(0x80,0x00,0x00)
#define LV_COLOR_YELLOW LV_COLOR_MAKE(0xFF,0xFF,0x00)
#define LV_COLOR_OLIVE LV_COLOR_MAKE(0x80,0x80,0x00)
#define LV_COLOR_LIME LV_COLOR_MAKE(0x00,0xFF,0x00)
#define LV_COLOR_GREEN LV_COLOR_MAKE(0x00,0x80,0x00)
#define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80,0x00,0x80)
#define LV_COLOR_CYAN LV_COLOR_MAKE(0x00,0xFF,0xFF)
#define LV_COLOR_AQUA LV_COLOR_CYAN
#define LV_COLOR_TEAL LV_COLOR_MAKE(0x00,0x80,0x80)
#define LV_COLOR_BLUE LV_COLOR_MAKE(0x00,0x00,0xFF)
#define LV_COLOR_NAVY LV_COLOR_MAKE(0x00,0x00,0x80)
#define LV_COLOR_MAGENTA LV_COLOR_MAKE(0xFF,0x00,0xFF)
#define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80,0x00,0x80)
#define LV_COLOR_ORANGE LV_COLOR_MAKE(0xFF,0xA5,0x00)
#define LV_OPA_TRANSP 0
@ -66,10 +78,10 @@ extern "C" {
#define LV_COLOR_SIZE 8
#elif LV_COLOR_DEPTH == 16
#define LV_COLOR_SIZE 16
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_SIZE 32
#else
#error "Invalid color depth (LV_COLOR_DEPTH in lv_conf.h)"
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
/**********************
@ -123,7 +135,7 @@ typedef union
uint8_t alpha;
};
uint32_t full;
} lv_color24_t;
} lv_color32_t;
#if LV_COLOR_DEPTH == 1
typedef uint8_t lv_color_int_t;
@ -134,11 +146,11 @@ typedef lv_color8_t lv_color_t;
#elif LV_COLOR_DEPTH == 16
typedef uint16_t lv_color_int_t;
typedef lv_color16_t lv_color_t;
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
typedef uint32_t lv_color_int_t;
typedef lv_color24_t lv_color_t;
typedef lv_color32_t lv_color_t;
#else
#error "Invalid LV_COLOR_DEPTH in misc_conf.h! Set it to 1, 8, 16 or 24!"
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
typedef uint8_t lv_opa_t;
@ -195,7 +207,7 @@ static inline uint8_t lv_color_to1(lv_color_t color)
} else {
return 0;
}
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
if((color.red & 0x80) ||
(color.green & 0x80) ||
(color.blue & 0x80)) {
@ -228,7 +240,7 @@ static inline uint8_t lv_color_to8(lv_color_t color)
ret.blue = color.blue >> 3; /* 5 - 2 = 3*/
return ret.full;
# endif
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
lv_color8_t ret;
ret.red = color.red >> 5; /* 8 - 3 = 5*/
ret.green = color.green >> 5; /* 8 - 3 = 5*/
@ -258,7 +270,7 @@ static inline uint16_t lv_color_to16(lv_color_t color)
return ret.full;
#elif LV_COLOR_DEPTH == 16
return color.full;
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
lv_color16_t ret;
# if LV_COLOR_16_SWAP == 0
ret.red = color.red >> 3; /* 8 - 5 = 3*/
@ -274,13 +286,13 @@ static inline uint16_t lv_color_to16(lv_color_t color)
#endif
}
static inline uint32_t lv_color_to24(lv_color_t color)
static inline uint32_t lv_color_to32(lv_color_t color)
{
#if LV_COLOR_DEPTH == 1
if(color.full == 0) return 0;
else return 0xFFFFFFFF;
#elif LV_COLOR_DEPTH == 8
lv_color24_t ret;
lv_color32_t ret;
ret.red = color.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
ret.green = color.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
ret.blue = color.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/
@ -288,21 +300,21 @@ static inline uint32_t lv_color_to24(lv_color_t color)
return ret.full;
#elif LV_COLOR_DEPTH == 16
# if LV_COLOR_16_SWAP == 0
lv_color24_t ret;
lv_color32_t ret;
ret.red = color.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
ret.green = color.green * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/
ret.blue = color.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
ret.alpha = 0xFF;
return ret.full;
# else
lv_color24_t ret;
lv_color32_t ret;
ret.red = color.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
ret.green = ((color.green_h << 3) + color.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/
ret.blue = color.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
ret.alpha = 0xFF;
return ret.full;
# endif
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
return color.full;
#endif
}
@ -311,8 +323,10 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
{
lv_color_t ret;
#if LV_COLOR_DEPTH != 1
/*LV_COLOR_DEPTH == 8, 16 or 32*/
ret.red = (uint16_t)((uint16_t) c1.red * mix + (c2.red * (255 - mix))) >> 8;
# if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP
/*If swapped Green is in 2 parts*/
uint16_t g_1 = (c1.green_h << 3) + c1.green_l;
uint16_t g_2 = (c2.green_h << 3) + c2.green_l;
uint16_t g_out = (uint16_t)((uint16_t) g_1 * mix + (g_2 * (255 - mix))) >> 8;
@ -322,10 +336,11 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
ret.green = (uint16_t)((uint16_t) c1.green * mix + (c2.green * (255 - mix))) >> 8;
# endif
ret.blue = (uint16_t)((uint16_t) c1.blue * mix + (c2.blue * (255 - mix))) >> 8;
# if LV_COLOR_DEPTH == 24
# if LV_COLOR_DEPTH == 32
ret.alpha = 0xFF;
# endif
#else
/*LV_COLOR_DEPTH == 1*/
ret.full = mix > LV_OPA_50 ? c1.full : c2.full;
#endif
@ -339,9 +354,9 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
*/
static inline uint8_t lv_color_brightness(lv_color_t color)
{
lv_color24_t c24;
c24.full = lv_color_to24(color);
uint16_t bright = 3 * c24.red + c24.blue + 4 * c24.green;
lv_color32_t c32;
c32.full = lv_color_to32(color);
uint16_t bright = 3 * c32.red + c32.blue + 4 * c32.green;
return (uint16_t) bright >> 3;
}
@ -358,7 +373,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
# else
# define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}})
# endif
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
#endif
#else
@ -368,7 +383,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{r8 >> 6, g8 >> 5, b8 >> 5}})
#elif LV_COLOR_DEPTH == 16
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{r8 >> 3, g8 >> 2, b8 >> 3}})
#elif LV_COLOR_DEPTH == 24
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{0xff, r8, g8, b8}}) /*Fix 0xff alpha*/
#endif
#endif

View File

@ -247,6 +247,26 @@ lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos)
return res;
}
/**
* Truncate the file size to the current position of the read write pointer
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_fs_open )
* @return LV_FS_RES_OK: no error, the file is read
* any error from lv_fs_res_t enum
*/
lv_fs_res_t lv_fs_trunc (lv_fs_file_t * file_p)
{
if(file_p->drv == NULL) {
return LV_FS_RES_INV_PARAM;
}
if(file_p->drv->tell == NULL) {
return LV_FS_RES_NOT_IMP;
}
lv_fs_res_t res = file_p->drv->trunc(file_p->file_d);
return res;
}
/**
* Give the size of a file bytes
* @param file_p pointer to a lv_fs_file_t variable
@ -269,6 +289,40 @@ lv_fs_res_t lv_fs_size(lv_fs_file_t * file_p, uint32_t * size)
return res;
}
/**
* Rename a file
* @param oldname path to the file
* @param newname path with the new name
* @return LV_FS_RES_OK or any error from 'fs_res_t'
*/
lv_fs_res_t lv_fs_rename (const char * oldname, const char * newname)
{
if(!oldname || !newname) return LV_FS_RES_INV_PARAM;
char letter = oldname[0];
lv_fs_drv_t * drv = lv_fs_get_drv(letter);
if(!drv) {
return LV_FS_RES_NOT_EX;
}
if(drv->ready != NULL) {
if(drv->ready() == false) {
return LV_FS_RES_HW_ERR;
}
}
if(drv->rename == NULL) return LV_FS_RES_NOT_IMP;
const char * old_real = lv_fs_get_real_path(oldname);
const char * new_real = lv_fs_get_real_path(newname);
lv_fs_res_t res = drv->rename(old_real, new_real);
return res;
}
/**
* Initialize a 'fs_read_dir_t' variable for directory reading
* @param rddir_p pointer to a 'fs_read_dir_t' variable
@ -315,6 +369,7 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t * rddir_p, char * fn)
{
if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) {
fn[0] = '\0';
return LV_FS_RES_INV_PARAM;
}

View File

@ -10,11 +10,14 @@
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#if USE_LV_FILESYSTEM
@ -30,7 +33,7 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
typedef enum
enum
{
LV_FS_RES_OK = 0,
LV_FS_RES_HW_ERR, /*Low level hardware error*/
@ -45,7 +48,8 @@ typedef enum
LV_FS_RES_OUT_OF_MEM, /*Not enough memory for an internal operation*/
LV_FS_RES_INV_PARAM, /*Invalid parameter among arguments*/
LV_FS_RES_UNKNOWN, /*Other unknown error*/
} lv_fs_res_t;
};
typedef uint8_t lv_fs_res_t;
struct __lv_fs_drv_t;
@ -62,11 +66,12 @@ typedef struct
struct __lv_fs_drv_t * drv;
} lv_fs_dir_t;
typedef enum
enum
{
LV_FS_MODE_WR = 0x01,
LV_FS_MODE_RD = 0x02,
} lv_fs_mode_t;
};
typedef uint8_t lv_fs_mode_t;
typedef struct __lv_fs_drv_t
{
@ -84,6 +89,7 @@ typedef struct __lv_fs_drv_t
lv_fs_res_t (*tell) (void * file_p, uint32_t * pos_p);
lv_fs_res_t (*trunc) (void * file_p);
lv_fs_res_t (*size) (void * file_p, uint32_t * size_p);
lv_fs_res_t (*rename) (const char * oldname, const char * newname);
lv_fs_res_t (*free) (uint32_t * total_p, uint32_t * free_p);
lv_fs_res_t (*dir_open) (void * rddir_p, const char * path);
@ -166,6 +172,14 @@ lv_fs_res_t lv_fs_seek (lv_fs_file_t * file_p, uint32_t pos);
*/
lv_fs_res_t lv_fs_tell (lv_fs_file_t * file_p, uint32_t * pos);
/**
* Truncate the file size to the current position of the read write pointer
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_fs_open )
* @return LV_FS_RES_OK: no error, the file is read
* any error from lv_fs_res_t enum
*/
lv_fs_res_t lv_fs_trunc (lv_fs_file_t * file_p);
/**
* Give the size of a file bytes
* @param file_p pointer to a lv_fs_file_t variable
@ -174,6 +188,14 @@ lv_fs_res_t lv_fs_tell (lv_fs_file_t * file_p, uint32_t * pos);
*/
lv_fs_res_t lv_fs_size (lv_fs_file_t * file_p, uint32_t * size);
/**
* Rename a file
* @param oldname path to the file
* @param newname path with the new name
* @return LV_FS_RES_OK or any error from 'fs_res_t'
*/
lv_fs_res_t lv_fs_rename (const char * oldname, const char * newname);
/**
* Initialize a 'fs_dir_t' variable for directory reading
* @param rddir_p pointer to a 'fs_read_dir_t' variable

View File

@ -13,7 +13,11 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#include <stdint.h>
/*********************
@ -25,14 +29,15 @@ extern "C" {
**********************/
/*Possible log level. For compatibility declare it independently from `USE_LV_LOG`*/
typedef enum
enum
{
LV_LOG_LEVEL_TRACE, /*A lot of logs to give detailed information*/
LV_LOG_LEVEL_INFO, /*Log important events*/
LV_LOG_LEVEL_WARN, /*Log if something unwanted happened but didn't caused problem*/
LV_LOG_LEVEL_ERROR, /*Only critical issue, when the system may fail*/
_LV_LOG_LEVEL_NUM
}lv_log_level_t;
};
typedef uint8_t lv_log_level_t;
#if USE_LV_LOG

View File

@ -37,7 +37,7 @@ extern "C" {
/**
* Possible priorities for lv_tasks
*/
typedef enum
enum
{
LV_TASK_PRIO_OFF = 0,
LV_TASK_PRIO_LOWEST,
@ -46,7 +46,8 @@ typedef enum
LV_TASK_PRIO_HIGH,
LV_TASK_PRIO_HIGHEST,
LV_TASK_PRIO_NUM,
} lv_task_prio_t;
};
typedef uint8_t lv_task_prio_t;
/**
* Descriptor of a lv_task

View File

@ -32,21 +32,23 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
typedef enum
enum
{
LV_TXT_FLAG_NONE = 0x00,
LV_TXT_FLAG_RECOLOR = 0x01, /*Enable parsing of recolor command*/
LV_TXT_FLAG_EXPAND = 0x02, /*Ignore width (Used by the library)*/
LV_TXT_FLAG_CENTER = 0x04, /*Align the text to the middle*/
LV_TXT_FLAG_RIGHT = 0x08, /*Align the text to the right*/
} lv_txt_flag_t;
};
typedef uint8_t lv_txt_flag_t;
typedef enum
enum
{
LV_TXT_CMD_STATE_WAIT, /*Waiting for command*/
LV_TXT_CMD_STATE_PAR, /*Processing the parameter*/
LV_TXT_CMD_STATE_IN, /*Processing the command*/
} lv_txt_cmd_state_t;
};
typedef uint8_t lv_txt_cmd_state_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -12,6 +12,7 @@
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_arc.h"
#include "../lv_themes/lv_theme.h"
/*********************
@ -76,7 +77,14 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new arc arc*/
if(copy == NULL) {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->preload);
} else {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
}
}
/*Copy an existing arc*/
else {
@ -228,32 +236,34 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
lv_draw_arc(x, y, r, mask, ext->angle_start, ext->angle_end, style, opa_scale);
if(style->body.radius == LV_RADIUS_CIRCLE) {
lv_coord_t thick_2 = style->body.thickness / 2;
lv_coord_t cir_x = ((r - thick_2) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT);
lv_coord_t cir_y = ((r - thick_2) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT);
/*Draw circle on the ends if enabled */
if(style->line.rounded) {
lv_coord_t thick_half = style->line.width / 2;
lv_coord_t cir_x = ((r - thick_half) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT);
lv_coord_t cir_y = ((r - thick_half) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT);
lv_style_t cir_style;
lv_style_copy(&cir_style, style);
cir_style.body.empty = 0;
cir_style.body.aux_color = style->body.main_color;
lv_style_copy(&cir_style, &lv_style_plain);
cir_style.body.grad_color = style->line.color;
cir_style.body.main_color = cir_style.body.grad_color;
cir_style.body.radius = LV_RADIUS_CIRCLE;
lv_area_t cir_area;
cir_area.x1 = cir_x + x - thick_2;
cir_area.y1 = cir_y + y - thick_2;
cir_area.x2 = cir_x + x + thick_2;
cir_area.y2 = cir_y + y + thick_2;
cir_area.x1 = cir_x + x - thick_half;
cir_area.y1 = cir_y + y - thick_half;
cir_area.x2 = cir_x + x + thick_half;
cir_area.y2 = cir_y + y + thick_half;
lv_draw_rect(&cir_area, mask, &cir_style, lv_obj_get_opa_scale(arc));
lv_draw_rect(&cir_area, mask, &cir_style, opa_scale);
cir_x = ((r - thick_2) * lv_trigo_sin(ext->angle_end) >> LV_TRIGO_SHIFT);
cir_y = ((r - thick_2) * lv_trigo_sin(ext->angle_end + 90) >> LV_TRIGO_SHIFT);
cir_x = ((r - thick_half) * lv_trigo_sin(ext->angle_end) >> LV_TRIGO_SHIFT);
cir_y = ((r - thick_half) * lv_trigo_sin(ext->angle_end + 90) >> LV_TRIGO_SHIFT);
cir_area.x1 = cir_x + x - thick_2;
cir_area.y1 = cir_y + y - thick_2;
cir_area.x2 = cir_x + x + thick_2;
cir_area.y2 = cir_y + y + thick_2;
cir_area.x1 = cir_x + x - thick_half;
cir_area.y1 = cir_y + y - thick_half;
cir_area.x2 = cir_x + x + thick_half;
cir_area.y2 = cir_y + y + thick_half;
lv_draw_rect(&cir_area, mask, &cir_style, lv_obj_get_opa_scale(arc));
lv_draw_rect(&cir_area, mask, &cir_style, opa_scale);
}
}

View File

@ -40,9 +40,11 @@ typedef struct {
/*Styles*/
typedef enum {
enum {
LV_ARC_STYLE_MAIN,
} lv_arc_style_t;
};
typedef uint8_t lv_arc_style_t;
/**********************

View File

@ -45,10 +45,11 @@ typedef struct
lv_style_t *style_indic; /*Style of the indicator*/
} lv_bar_ext_t;
typedef enum {
enum {
LV_BAR_STYLE_BG,
LV_BAR_STYLE_INDIC,
} lv_bar_style_t;
};
typedef uint8_t lv_bar_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -39,7 +39,7 @@ extern "C" {
/* Button states
* It can be used not only by buttons but other button-like objects too*/
typedef enum
enum
{
LV_BTN_STATE_REL,
LV_BTN_STATE_PR,
@ -47,16 +47,19 @@ typedef enum
LV_BTN_STATE_TGL_PR,
LV_BTN_STATE_INA,
LV_BTN_STATE_NUM,
} lv_btn_state_t;
};
typedef uint8_t lv_btn_state_t;
typedef enum
enum
{
LV_BTN_ACTION_CLICK,
LV_BTN_ACTION_PR,
LV_BTN_ACTION_LONG_PR,
LV_BTN_ACTION_LONG_PR_REPEAT,
LV_BTN_ACTION_NUM,
} lv_btn_action_t;
};
typedef uint8_t lv_btn_action_t;
/*Data of button*/
typedef struct
@ -76,13 +79,14 @@ typedef struct
} lv_btn_ext_t;
/*Styles*/
typedef enum {
enum {
LV_BTN_STYLE_REL,
LV_BTN_STYLE_PR,
LV_BTN_STYLE_TGL_REL,
LV_BTN_STYLE_TGL_PR,
LV_BTN_STYLE_INA,
} lv_btn_style_t;
};
typedef uint8_t lv_btn_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -64,7 +64,7 @@ static lv_signal_func_t ancestor_signal;
*/
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("button matrix create started");
LV_LOG_TRACE("button matrix create started");
/*Create the ancestor object*/
lv_obj_t * new_btnm = lv_obj_create(par, copy);
@ -124,7 +124,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
}
LV_LOG_INFO("button matrix created");
LV_LOG_INFO("button matrix created");
return new_btnm;
}
@ -505,11 +505,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
lv_point_t p;
if(sign == LV_SIGNAL_CLEANUP) {
lv_mem_free(ext->button_areas);
}
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
} else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
lv_btnm_set_map(btnm, ext->map_p);
}
else if(sign == LV_SIGNAL_PRESSING) {
} else if(sign == LV_SIGNAL_PRESSING) {
uint16_t btn_pr;
/*Search the pressed area*/
lv_indev_get_point(param, &p);
@ -549,8 +547,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
}
}
else if(sign == LV_SIGNAL_RELEASED) {
} else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
@ -586,34 +583,31 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
/*Leave the clicked button as pressed if this the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm);
if(lv_group_get_focused(g) != btnm) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
ext->btn_id_pr = LV_BTNM_PR_NONE;
}
#else
ext->btn_id_pr = LV_BTNM_PR_NONE;
#endif
}
}
else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_FOCUS) {
} else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_indev_t * indev = lv_indev_get_act();
if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
lv_point_t p;
lv_indev_get_point(indev, &p);
uint16_t btn_i = get_button_from_point(btnm, &p);
ext->btn_id_pr = btn_i;
} else {
lv_indev_t * indev = lv_indev_get_act();
if(lv_obj_is_focused(btnm) && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
lv_point_t p1;
lv_indev_get_point(indev, &p1);
uint16_t btn_i = get_button_from_point(btnm, &p1);
ext->btn_id_pr = btn_i;
} else {
ext->btn_id_pr = 0;
}
}
#else
ext->btn_id_pr = 0;
#endif
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_CONTROLL) {
} else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char *)param);
if(c == LV_GROUP_KEY_RIGHT) {
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
@ -624,8 +618,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
if(ext->btn_id_pr > 0) ext->btn_id_pr--;
lv_obj_invalidate(btnm);
}
else if(c == LV_GROUP_KEY_DOWN) {
} else if(c == LV_GROUP_KEY_DOWN) {
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
/*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_PR_NONE) {
@ -645,8 +638,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(area_below < ext->btn_cnt) ext->btn_id_pr = area_below;
}
lv_obj_invalidate(btnm);
}
else if(c == LV_GROUP_KEY_UP) {
} else if(c == LV_GROUP_KEY_UP) {
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
/*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_PR_NONE) {
@ -666,8 +658,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
lv_obj_invalidate(btnm);
}
else if(c == LV_GROUP_KEY_ENTER) {
} else if(c == LV_GROUP_KEY_ENTER) {
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) {
@ -675,19 +666,17 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
}
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_btnm";
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
}
else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_btnm";
}
return res;

View File

@ -62,14 +62,15 @@ typedef struct
uint8_t toggle :1; /*Enable toggling*/
} lv_btnm_ext_t;
typedef enum {
enum {
LV_BTNM_STYLE_BG,
LV_BTNM_STYLE_BTN_REL,
LV_BTNM_STYLE_BTN_PR,
LV_BTNM_STYLE_BTN_TGL_REL,
LV_BTNM_STYLE_BTN_TGL_PR,
LV_BTNM_STYLE_BTN_INA,
} lv_btnm_style_t;
};
typedef uint8_t lv_btnm_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -13,6 +13,7 @@
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_misc/lv_math.h"
#include "../lv_core/lv_indev.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
@ -21,11 +22,12 @@
/**********************
* TYPEDEFS
**********************/
typedef enum {
enum {
DAY_DRAW_PREV_MONTH,
DAY_DRAW_ACT_MONTH,
DAY_DRAW_NEXT_MONTH,
} day_draw_state_t;
};
typedef uint8_t day_draw_state_t;
/**********************
* STATIC PROTOTYPES
@ -48,7 +50,7 @@ static uint8_t is_leap_year(uint32_t year);
**********************/
static lv_signal_func_t ancestor_signal;
static lv_design_func_t ancestor_design;
static const char * day_name[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
static const char * month_name[12] = {"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
@ -99,7 +101,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->month_names = NULL;
ext->style_header = &lv_style_plain_color;
ext->style_header_pr = &lv_style_pretty_color;
ext->style_highlighted = &lv_style_plain_color;
ext->style_highlighted_days = &lv_style_plain_color;
ext->style_inactive_days = &lv_style_btn_ina;
ext->style_week_box = &lv_style_plain_color;
ext->style_today_box = &lv_style_pretty_color;
@ -114,6 +116,28 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_size(new_calendar, LV_DPI * 2, LV_DPI * 2);
lv_obj_set_style(new_calendar, &lv_style_pretty);
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->calendar.bg);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->calendar.header);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->calendar.header_pr);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->calendar.day_names);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->calendar.week_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->calendar.today_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->calendar.highlighted_days);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->calendar.inactive_days);
} else {
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, ext->style_header_pr);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, ext->style_day_names);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, ext->style_week_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days);
}
}
/*Copy an existing calendar*/
else {
@ -132,7 +156,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->month_names = copy_ext->month_names;
ext->style_header = copy_ext->style_header;
ext->style_header_pr = copy_ext->style_header_pr;
ext->style_highlighted = copy_ext->style_highlighted;
ext->style_highlighted_days = copy_ext->style_highlighted_days;
ext->style_inactive_days = copy_ext->style_inactive_days;
ext->style_week_box = copy_ext->style_week_box;
ext->style_today_box = copy_ext->style_today_box;
@ -255,7 +279,7 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
ext->style_header_pr = style;
break;
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
ext->style_highlighted = style;
ext->style_highlighted_days = style;
break;
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
ext->style_inactive_days = style;
@ -362,7 +386,7 @@ lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_
case LV_CALENDAR_STYLE_DAY_NAMES:
return ext->style_day_names;
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
return ext->style_highlighted;
return ext->style_highlighted_days;
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
return ext->style_inactive_days;
case LV_CALENDAR_STYLE_WEEK_BOX:
@ -549,9 +573,14 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_rect(&header_area, mask, ext->style_header, opa_scale);
/*Add the month name*/
/*Add the year + month name*/
char txt_buf[64];
lv_math_num_to_str(ext->showed_date.year, txt_buf);
txt_buf[4] = ' ';
txt_buf[5] = '\0';
strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
header_area.y1 += ext->style_header->body.padding.ver;
lv_draw_label(&header_area, mask, ext->style_header, opa_scale, get_month_name(calendar, ext->showed_date.month), LV_TXT_FLAG_CENTER, NULL);
lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf , LV_TXT_FLAG_CENTER, NULL);
/*Add the left arrow*/
lv_style_t * arrow_style = ext->btn_pressing < 0 ? ext->style_header_pr : ext->style_header;
@ -701,17 +730,17 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
is_highlighted(calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0),
ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1,
day_cnt)) {
final_style = ext->style_highlighted;
final_style = ext->style_highlighted_days;
} else if(draw_state == DAY_DRAW_ACT_MONTH &&
is_highlighted(calendar, ext->showed_date.year,
ext->showed_date.month,
day_cnt)) {
final_style = ext->style_highlighted;
final_style = ext->style_highlighted_days;
} else if(draw_state == DAY_DRAW_NEXT_MONTH &&
is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1,
day_cnt)) {
final_style = ext->style_highlighted;
final_style = ext->style_highlighted_days;
} else if(month_of_today_shown && day_cnt == ext->today.day && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_today_box;
else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_week_box;
else final_style = act_style;

View File

@ -53,14 +53,14 @@ typedef struct {
lv_style_t * style_header;
lv_style_t * style_header_pr;
lv_style_t * style_day_names;
lv_style_t * style_highlighted;
lv_style_t * style_highlighted_days;
lv_style_t * style_inactive_days;
lv_style_t * style_week_box;
lv_style_t * style_today_box;
} lv_calendar_ext_t;
/*Styles*/
typedef enum {
enum {
LV_CALENDAR_STYLE_BG, /*Also the style of the "normal" date numbers*/
LV_CALENDAR_STYLE_HEADER,
LV_CALENDAR_STYLE_HEADER_PR,
@ -69,7 +69,9 @@ typedef enum {
LV_CALENDAR_STYLE_INACTIVE_DAYS,
LV_CALENDAR_STYLE_WEEK_BOX,
LV_CALENDAR_STYLE_TODAY_BOX,
} lv_calendar_style_t;
};
typedef uint8_t lv_calendar_style_t;
/**********************

View File

@ -83,6 +83,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_btn_set_layout(new_cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(new_cb, true, true);
lv_btn_set_toggle(new_cb, true);
lv_obj_set_protect(new_cb, LV_PROTECT_PRESS_LOST);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();

View File

@ -51,14 +51,15 @@ typedef struct
lv_obj_t * label; /*Pointer to label*/
} lv_cb_ext_t;
typedef enum {
enum {
LV_CB_STYLE_BG,
LV_CB_STYLE_BOX_REL,
LV_CB_STYLE_BOX_PR,
LV_CB_STYLE_BOX_TGL_REL,
LV_CB_STYLE_BOX_TGL_PR,
LV_CB_STYLE_BOX_INA,
} lv_cb_style_t;
};
typedef uint8_t lv_cb_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -58,12 +58,13 @@ typedef struct
} lv_chart_ext_t;
/*Chart types*/
typedef enum
enum
{
LV_CHART_TYPE_LINE = 0x01,
LV_CHART_TYPE_COLUMN = 0x02,
LV_CHART_TYPE_POINT = 0x04,
} lv_chart_type_t;
};
typedef uint8_t lv_chart_type_t;
/**********************

View File

@ -32,7 +32,7 @@ extern "C" {
**********************/
/*Layout options*/
typedef enum
enum
{
LV_LAYOUT_OFF = 0,
LV_LAYOUT_CENTER,
@ -44,7 +44,8 @@ typedef enum
LV_LAYOUT_ROW_B, /*Row bottom align*/
LV_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
LV_LAYOUT_GRID, /*Align same-sized object into a grid*/
} lv_layout_t;
};
typedef uint8_t lv_layout_t;
typedef struct
{

View File

@ -57,11 +57,12 @@ typedef struct
lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/
} lv_ddlist_ext_t;
typedef enum {
enum {
LV_DDLIST_STYLE_BG,
LV_DDLIST_STYLE_SEL,
LV_DDLIST_STYLE_SB,
} lv_ddlist_style_t;
};
typedef uint8_t lv_ddlist_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -54,7 +54,7 @@ static lv_signal_func_t ancestor_signal;
*/
lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("image create started");
LV_LOG_TRACE("image create started");
lv_obj_t * new_img = NULL;
@ -83,15 +83,15 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_obj_set_click(new_img, false);
/* Enable auto size for non screens
/* Enable auto size for non screens
* because image screens are wallpapers
* and must be screen sized*/
if(par != NULL) {
ext->auto_size = 1;
lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
ext->auto_size = 1;
lv_obj_set_style(new_img, &lv_style_plain); /*Inherit the style by default*/
} else {
ext->auto_size = 0;
lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
ext->auto_size = 0;
lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
}
} else {
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
@ -103,7 +103,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
}
LV_LOG_INFO("image created");
LV_LOG_INFO("image created");
return new_img;
}
@ -135,13 +135,12 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
}
lv_img_header_t header;
lv_img_dsc_get_info(src_img, &header);
lv_img_dsc_get_info(src_img, &header);
/*Save the source*/
if(src_type == LV_IMG_SRC_VARIABLE) {
ext->src = src_img;
}
else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
/*Save the source*/
if(src_type == LV_IMG_SRC_VARIABLE) {
ext->src = src_img;
} else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
/* If the new and the old src are the same then it was only a refresh.*/
if(ext->src != src_img) {
lv_mem_free(ext->src);
@ -151,21 +150,21 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
strcpy(new_str, src_img);
ext->src = new_str;
}
}
}
if(src_type == LV_IMG_SRC_SYMBOL) {
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/
lv_style_t * style = lv_img_get_style(img);
lv_point_t size;
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
header.w = size.x;
header.h = size.y;
}
if(src_type == LV_IMG_SRC_SYMBOL) {
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/
lv_style_t * style = lv_img_get_style(img);
lv_point_t size;
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
header.w = size.x;
header.h = size.y;
}
ext->src_type = src_type;
ext->w = header.w;
ext->h = header.h;
ext->cf = header.cf;
ext->w = header.w;
ext->h = header.h;
ext->cf = header.cf;
if(lv_img_get_auto_size(img) != false) {
lv_obj_set_size(img, ext->w, ext->h);
@ -278,12 +277,10 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
}
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
lv_draw_label(&coords, mask, style, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL);
} else {
/*Trigger the error handler of image drawer*/
LV_LOG_WARN("Image source type is unknown in lv_img_design");
lv_draw_img(&img->coords, mask, NULL, style, opa_scale);
}
}

View File

@ -80,6 +80,11 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
else {
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_REL, copy_ext->img_src[LV_BTN_STATE_REL]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_PR, copy_ext->img_src[LV_BTN_STATE_PR]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_TGL_REL, copy_ext->img_src[LV_BTN_STATE_TGL_REL]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_TGL_PR, copy_ext->img_src[LV_BTN_STATE_TGL_PR]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_INA, copy_ext->img_src[LV_BTN_STATE_INA]);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_imgbtn);
}
@ -99,7 +104,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
* @param state for which state set the new image (from `lv_btn_state_t`) `
* @param src pointer to an image source (a C array or path to a file)
*/
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, void * src)
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src)
{
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);

View File

@ -41,19 +41,20 @@ extern "C" {
typedef struct {
lv_btn_ext_t btn; /*Ext. of ancestor*/
/*New data for this type */
void * img_src[LV_BTN_STATE_NUM]; /*Store images to each state*/
const void * img_src[LV_BTN_STATE_NUM]; /*Store images to each state*/
lv_img_cf_t act_cf; /*Color format of the currently active image*/
} lv_imgbtn_ext_t;
/*Styles*/
typedef enum {
enum {
LV_IMGBTN_STYLE_REL,
LV_IMGBTN_STYLE_PR,
LV_IMGBTN_STYLE_TGL_REL,
LV_IMGBTN_STYLE_TGL_PR,
LV_IMGBTN_STYLE_INA,
} lv_imgbtn_style_t;
};
typedef uint8_t lv_imgbtn_style_t;
/**********************
@ -83,7 +84,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy);
* @param state for which state set the new image (from `lv_btn_state_t`) `
* @param src pointer to an image source (a C array or path to a file)
*/
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, void * src);
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src);
/**
* Enable the toggled states. On release the button will change from/to toggled state.

View File

@ -41,11 +41,11 @@ extern "C" {
* TYPEDEFS
**********************/
typedef enum {
enum {
LV_KB_MODE_TEXT,
LV_KB_MODE_NUM,
} lv_kb_mode_t;
};
typedef uint8_t lv_kb_mode_t;
/*Data of keyboard*/
typedef struct {
@ -58,14 +58,16 @@ typedef struct {
lv_action_t hide_action; /*Called when the "Hide" button is clicked*/
} lv_kb_ext_t;
typedef enum {
enum {
LV_KB_STYLE_BG,
LV_KB_STYLE_BTN_REL,
LV_KB_STYLE_BTN_PR,
LV_KB_STYLE_BTN_TGL_REL,
LV_KB_STYLE_BTN_TGL_PR,
LV_KB_STYLE_BTN_INA,
} lv_kb_style_t;
};
typedef uint8_t lv_kb_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -37,21 +37,23 @@ extern "C" {
**********************/
/*Long mode behaviors. Used in 'lv_label_ext_t' */
typedef enum
enum
{
LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/
LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object height*/
LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text on the parent (move the label object)*/
LV_LABEL_LONG_DOT, /*Keep the size and write dots at the end if the text is too long*/
LV_LABEL_LONG_ROLL, /*Keep the size and roll the text infinitely*/
} lv_label_long_mode_t;
};
typedef uint8_t lv_label_long_mode_t;
/*Label align policy*/
typedef enum {
enum {
LV_LABEL_ALIGN_LEFT,
LV_LABEL_ALIGN_CENTER,
LV_LABEL_ALIGN_RIGHT,
} lv_label_align_t;
};
typedef uint8_t lv_label_align_t;
/*Data of label*/
typedef struct

View File

@ -223,7 +223,8 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
lv_point_t p2;
lv_coord_t h = lv_obj_get_height(line);
uint16_t i;
lv_style_t circle_style;
lv_style_t circle_style; /*If rounded...*/
lv_style_copy(&circle_style, style);
circle_style.body.radius = LV_RADIUS_CIRCLE;
circle_style.body.main_color = style->line.color;
@ -231,7 +232,7 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
circle_style.body.opa = style->line.opa;
lv_area_t circle_area;
/*Read all pints and draw the lines*/
/*Read all points and draw the lines*/
for(i = 0; i < ext->point_num - 1; i++) {
p1.x = ext->point_array[i].x + x_ofs;
@ -246,19 +247,24 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
}
lv_draw_line(&p1, &p2, mask, style, opa_scale);
circle_area.x1 = p1.x - (style->line.width >> 1);
circle_area.y1 = p1.y - (style->line.width >> 1);
circle_area.x2 = p1.x + (style->line.width >> 1);
circle_area.y2 = p1.y + (style->line.width >> 1);
// lv_draw_rect(&circle_area, mask, &circle_style);
/*Draw circle on the joints if enabled*/
if(style->line.rounded) {
circle_area.x1 = p1.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.y1 = p1.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.x2 = p1.x + ((style->line.width - 1) >> 1);
circle_area.y2 = p1.y + ((style->line.width - 1) >> 1);
lv_draw_rect(&circle_area, mask, &circle_style, opa_scale);
}
}
circle_area.x1 = p2.x - (style->line.width >> 1);
circle_area.y1 = p2.y - (style->line.width >> 1);
circle_area.x2 = p2.x + (style->line.width >> 1);
circle_area.y2 = p2.y + (style->line.width >> 1);
// lv_draw_rect(&circle_area, mask, &circle_style);
/*Draw circle on the last point too if enabled*/
if(style->line.rounded) {
circle_area.x1 = p2.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.y1 = p2.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
circle_area.x2 = p2.x + ((style->line.width - 1) >> 1);
circle_area.y2 = p2.y + ((style->line.width - 1) >> 1);
lv_draw_rect(&circle_area, mask, &circle_style, opa_scale);
}
}
return true;
}

View File

@ -150,7 +150,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
* Delete all children of the scrl object, without deleting scrl child.
* @param obj pointer to an object
*/
void lv_list_clear(lv_obj_t * obj)
void lv_list_clean(lv_obj_t * obj)
{
lv_obj_t * scrl = lv_page_get_scrl(obj);
lv_obj_clean(scrl);

View File

@ -61,7 +61,7 @@ typedef struct
#endif
} lv_list_ext_t;
typedef enum {
enum {
LV_LIST_STYLE_BG,
LV_LIST_STYLE_SCRL,
LV_LIST_STYLE_SB,
@ -70,7 +70,9 @@ typedef enum {
LV_LIST_STYLE_BTN_TGL_REL,
LV_LIST_STYLE_BTN_TGL_PR,
LV_LIST_STYLE_BTN_INA,
} lv_list_style_t;
};
typedef uint8_t lv_list_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -88,7 +90,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy);
* Delete all children of the scrl object, without deleting scrl child.
* @param obj pointer to an object
*/
void lv_list_clear(lv_obj_t *obj);
void lv_list_clean(lv_obj_t *obj);
/*======================
* Add/remove functions

View File

@ -70,7 +70,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
ext->min_value = 0;
ext->max_value = 100;
ext->cur_value = 0;
ext->line_cnt = 31; /*Odd scale number looks better*/
ext->line_cnt = 21; /*Odd scale number looks better*/
ext->scale_angle = 240; /*(scale_num - 1) * N looks better */
/*The signal and design functions are not copied so set them here*/

View File

@ -58,7 +58,7 @@ typedef struct
uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/
} lv_mbox_ext_t;
typedef enum {
enum {
LV_MBOX_STYLE_BG,
LV_MBOX_STYLE_BTN_BG,
LV_MBOX_STYLE_BTN_REL,
@ -66,7 +66,8 @@ typedef enum {
LV_MBOX_STYLE_BTN_TGL_REL,
LV_MBOX_STYLE_BTN_TGL_PR,
LV_MBOX_STYLE_BTN_INA,
} lv_mbox_style_t;
};
typedef uint8_t lv_mbox_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -9,6 +9,7 @@ CSRCS += lv_preload.c
CSRCS += lv_roller.c
CSRCS += lv_tabview.c
CSRCS += lv_btn.c
CSRCS += lv_calendar.c
CSRCS += lv_chart.c
CSRCS += lv_gauge.c
CSRCS += lv_label.c

View File

@ -46,10 +46,11 @@ typedef struct {
/*Styles*/
typedef enum {
enum {
LV_TEMPL_STYLE_X,
LV_TEMPL_STYLE_Y,
} lv_templ_style_t;
};
typedef uint8_t lv_templ_style_t;
/**********************

View File

@ -151,7 +151,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
* Delete all children of the scrl object, without deleting scrl child.
* @param obj pointer to an object
*/
void lv_page_clear(lv_obj_t * obj)
void lv_page_clean(lv_obj_t * obj)
{
lv_obj_t * scrl = lv_page_get_scrl(obj);
lv_obj_clean(scrl);

View File

@ -38,7 +38,7 @@ extern "C" {
**********************/
/*Scrollbar modes: shows when should the scrollbars be visible*/
typedef enum
enum
{
LV_SB_MODE_OFF = 0x0, /*Never show scrollbars*/
LV_SB_MODE_ON = 0x1, /*Always show scrollbars*/
@ -46,7 +46,8 @@ typedef enum
LV_SB_MODE_AUTO = 0x3, /*Show scrollbars when the scrollable container is large enough to be scrolled*/
LV_SB_MODE_HIDE = 0x4, /*Hide the scroll bar temporally*/
LV_SB_MODE_UNHIDE = 0x5, /*Unhide the previously hidden scrollbar. Recover it's type too*/
} lv_sb_mode_t;
};
typedef uint8_t lv_sb_mode_t;
/*Data of page*/
typedef struct
@ -62,17 +63,17 @@ typedef struct
lv_area_t ver_area; /*Vertical scrollbar area relative to the page (Handled by the library)*/
uint8_t hor_draw :1; /*1: horizontal scrollbar is visible now (Handled by the library)*/
uint8_t ver_draw :1; /*1: vertical scrollbar is visible now (Handled by the library)*/
uint8_t mode :3; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/
lv_sb_mode_t mode:3; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/
} sb;
uint8_t arrow_scroll :1; /*1: Enable scrolling with LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN*/
} lv_page_ext_t;
typedef enum {
enum {
LV_PAGE_STYLE_BG,
LV_PAGE_STYLE_SCRL,
LV_PAGE_STYLE_SB,
} lv_page_style_t;
};
typedef uint8_t lv_page_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -90,7 +91,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy);
* Delete all children of the scrl object, without deleting scrl child.
* @param obj pointer to an object
*/
void lv_page_clear(lv_obj_t *obj);
void lv_page_clean(lv_obj_t *obj);
/**
* Get the press action of the page

View File

@ -12,6 +12,7 @@
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_rect.h"
#include "../lv_draw/lv_draw_arc.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
@ -95,7 +96,16 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new pre loader pre loader*/
if(copy == NULL) {
lv_obj_set_style(new_preload, &lv_style_pretty_color);
lv_obj_set_size(new_preload, LV_DPI / 2, LV_DPI / 2);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->preload);
} else {
lv_obj_set_style(new_preload, &lv_style_pretty_color);
}
}
/*Copy an existing pre loader*/
else {
@ -268,25 +278,28 @@ static bool lv_preload_design(lv_obj_t * preload, const lv_area_t * mask, lv_des
/*Draw a circle as background*/
lv_style_t * style = lv_arc_get_style(preload, LV_ARC_STYLE_MAIN);
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(preload), lv_obj_get_height(preload))) / 2;
lv_coord_t x = preload->coords.x1 + lv_obj_get_width(preload) / 2;
lv_coord_t y = preload->coords.y1 + lv_obj_get_height(preload) / 2;
if(style->body.border.width > 0) {
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(preload), lv_obj_get_height(preload))) / 2;
r -= LV_MATH_MIN(style->body.padding.hor, style->body.padding.ver);
lv_style_t bg_style;
lv_style_copy(&bg_style, &lv_style_plain);
bg_style.body.empty = 1;
bg_style.body.radius = LV_RADIUS_CIRCLE;
bg_style.body.border.color = style->body.aux_color;
bg_style.body.border.width = style->body.thickness;
lv_coord_t x = preload->coords.x1 + lv_obj_get_width(preload) / 2;
lv_coord_t y = preload->coords.y1 + lv_obj_get_height(preload) / 2;
lv_area_t bg_area;
bg_area.x1 = x - r;
bg_area.y1 = y - r;
bg_area.x2 = x + r;
bg_area.y2 = y + r;
lv_style_t bg_style;
lv_style_copy(&bg_style, &lv_style_plain);
bg_style.body.empty = 1;
bg_style.body.radius = LV_RADIUS_CIRCLE;
bg_style.body.border.color = style->body.border.color;
bg_style.body.border.width = style->body.border.width;
if(style->body.empty == 0) lv_draw_rect(&bg_area, mask, &bg_style, lv_obj_get_opa_scale(preload));
lv_area_t bg_area;
bg_area.x1 = x - r;
bg_area.y1 = y - r;
bg_area.x2 = x + r;
bg_area.y2 = y + r;
lv_draw_rect(&bg_area, mask, &bg_style, lv_obj_get_opa_scale(preload));
}
/*Draw the arc above the background circle */
ancestor_design(preload, mask, mode);
}

View File

@ -41,9 +41,10 @@ extern "C" {
* TYPEDEFS
**********************/
typedef enum {
enum {
LV_PRELOAD_TYPE_SPINNING_ARC,
} lv_preloader_type_t;
};
typedef uint8_t lv_preloader_type_t;
/*Data of pre loader*/
typedef struct {
@ -55,10 +56,10 @@ typedef struct {
/*Styles*/
typedef enum {
enum {
LV_PRELOAD_STYLE_MAIN,
} lv_preload_style_t;
};
typedef uint8_t lv_preload_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -42,10 +42,11 @@ typedef struct {
/*New data for this type */
} lv_roller_ext_t;
typedef enum {
enum {
LV_ROLLER_STYLE_BG,
LV_ROLLER_STYLE_SEL,
} lv_roller_style_t;
};
typedef uint8_t lv_roller_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -48,12 +48,13 @@ typedef struct
} lv_slider_ext_t;
/*Built-in styles of slider*/
typedef enum
enum
{
LV_SLIDER_STYLE_BG,
LV_SLIDER_STYLE_INDIC,
LV_SLIDER_STYLE_KNOB,
} lv_slider_style_t;
};
typedef uint8_t lv_slider_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -46,12 +46,13 @@ typedef struct
uint8_t changed :1; /*Indicates the switch explicitly changed by drag*/
} lv_sw_ext_t;
typedef enum {
enum {
LV_SW_STYLE_BG,
LV_SW_STYLE_INDIC,
LV_SW_STYLE_KNOB_OFF,
LV_SW_STYLE_KNOB_ON,
} lv_sw_style_t;
};
typedef uint8_t lv_sw_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -43,14 +43,15 @@ extern "C" {
* TYPEDEFS
**********************/
typedef enum {
enum {
LV_CURSOR_NONE,
LV_CURSOR_LINE,
LV_CURSOR_BLOCK,
LV_CURSOR_OUTLINE,
LV_CURSOR_UNDERLINE,
LV_CURSOR_HIDDEN = 0x10, /*Or it to any value to hide the cursor temporally*/
} lv_cursor_type_t;
};
typedef uint8_t lv_cursor_type_t;
/*Data of text area*/
typedef struct
@ -67,16 +68,17 @@ typedef struct
lv_style_t *style; /*Style of the cursor (NULL to use label's style)*/
lv_coord_t valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/
uint16_t pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/
lv_cursor_type_t type; /*Shape of the cursor*/
lv_cursor_type_t type:2; /*Shape of the cursor*/
uint8_t state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
} cursor;
} lv_ta_ext_t;
typedef enum {
enum {
LV_TA_STYLE_BG,
LV_TA_STYLE_SB,
LV_TA_STYLE_CURSOR,
} lv_ta_style_t;
};
typedef uint8_t lv_ta_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -90,6 +90,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->indic = NULL;
ext->btns = NULL;
ext->tab_load_action = NULL;
ext->btns_pos = LV_TABVIEW_BTNS_POS_TOP;
ext->anim_time = LV_TABVIEW_ANIM_TIME;

View File

@ -45,6 +45,13 @@ extern "C" {
/* parametes: pointer to a tabview object, tab_id*/
typedef void (*lv_tabview_action_t)(lv_obj_t *, uint16_t);
enum {
LV_TABVIEW_BTNS_POS_TOP,
LV_TABVIEW_BTNS_POS_BOTTOM,
};
typedef uint8_t lv_tabview_btns_pos_t;
/*Data of tab*/
typedef struct
{
@ -61,11 +68,11 @@ typedef struct
uint8_t slide_enable :1; /*1: enable horizontal sliding by touch pad*/
uint8_t draging :1;
uint8_t drag_hor :1;
uint8_t btns_pos : 1;
lv_tabview_btns_pos_t btns_pos :1;
lv_tabview_action_t tab_load_action;
} lv_tabview_ext_t;
typedef enum {
enum {
LV_TABVIEW_STYLE_BG,
LV_TABVIEW_STYLE_INDIC,
LV_TABVIEW_STYLE_BTN_BG,
@ -73,12 +80,8 @@ typedef enum {
LV_TABVIEW_STYLE_BTN_PR,
LV_TABVIEW_STYLE_BTN_TGL_REL,
LV_TABVIEW_STYLE_BTN_TGL_PR,
} lv_tabview_style_t;
typedef enum {
LV_TABVIEW_BTNS_POS_TOP,
LV_TABVIEW_BTNS_POS_BOTTOM,
} lv_tabview_btns_pos_t;
};
typedef uint8_t lv_tabview_style_t;
/**********************
* GLOBAL PROTOTYPES

View File

@ -146,7 +146,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
* Delete all children of the scrl object, without deleting scrl child.
* @param obj pointer to an object
*/
void lv_win_clear(lv_obj_t * obj)
void lv_win_clean(lv_obj_t * obj)
{
lv_obj_t * scrl = lv_page_get_scrl(obj);
lv_obj_clean(scrl);
@ -228,6 +228,27 @@ void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
lv_win_realign(win);
}
/**
* Set the layout of the window
* @param win pointer to a window object
* @param layout the layout from 'lv_layout_t'
*/
void lv_win_set_layout(lv_obj_t *win, lv_layout_t layout)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_page_set_scrl_layout(ext->page, layout);
}
/**
* Set the scroll bar mode of a window
* @param win pointer to a window object
* @param sb_mode the new scroll bar mode from 'lv_sb_mode_t'
*/
void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_page_set_sb_mode(ext->page, sb_mode);
}
/**
* Set a style of a window
@ -276,7 +297,6 @@ void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, lv_style_t * style)
btn = lv_obj_get_child_back(ext->header, btn);
}
}
}
@ -331,6 +351,42 @@ lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn)
return win;
}
/**
* Get the layout of a window
* @param win pointer to a window object
* @return the layout of the window (from 'lv_layout_t')
*/
lv_layout_t lv_win_get_layout(lv_obj_t *win)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
return lv_page_get_scrl_layout(ext->page);
}
/**
* Get the scroll bar mode of a window
* @param win pointer to a window object
* @return the scroll bar mode of the window (from 'lv_sb_mode_t')
*/
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t *win)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
return lv_page_get_sb_mode(ext->page);
}
/**
* Get width of the content area (page scrollable) of the window
* @param win pointer to a window object
* @return the width of the content_bg area
*/
lv_coord_t lv_win_get_width(lv_obj_t * win)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
lv_style_t * style_scrl = lv_obj_get_style(scrl);
return lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor;
}
/**
* Get a style of a window
* @param win pointer to a button object

View File

@ -68,7 +68,7 @@ typedef struct
lv_coord_t btn_size; /*Size of the control buttons (square)*/
} lv_win_ext_t;
typedef enum {
enum {
LV_WIN_STYLE_BG,
LV_WIN_STYLE_CONTENT_BG,
LV_WIN_STYLE_CONTENT_SCRL,
@ -76,7 +76,8 @@ typedef enum {
LV_WIN_STYLE_HEADER,
LV_WIN_STYLE_BTN_REL,
LV_WIN_STYLE_BTN_PR,
} lv_win_style_t;
};
typedef uint8_t lv_win_style_t;
/**********************
* GLOBAL PROTOTYPES
@ -94,7 +95,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy);
* Delete all children of the scrl object, without deleting scrl child.
* @param obj pointer to an object
*/
void lv_win_clear(lv_obj_t *obj);
void lv_win_clean(lv_obj_t *obj);
/*======================
* Add/remove functions
@ -134,13 +135,6 @@ void lv_win_set_title(lv_obj_t * win, const char * title);
*/
void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size);
/**
* Set the scroll bar mode of a window
* @param win pointer to a window object
* @param sb_mode the new scroll bar mode from 'lv_sb_mode_t'
*/
void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode);
/**
* Set the layout of the window
* @param win pointer to a window object
@ -148,6 +142,13 @@ void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode);
*/
void lv_win_set_layout(lv_obj_t *win, lv_layout_t layout);
/**
* Set the scroll bar mode of a window
* @param win pointer to a window object
* @param sb_mode the new scroll bar mode from 'lv_sb_mode_t'
*/
void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode);
/**
* Set a style of a window
* @param win pointer to a window object
@ -190,6 +191,27 @@ lv_coord_t lv_win_get_btn_size(const lv_obj_t * win);
*/
lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn);
/**
* Get the layout of a window
* @param win pointer to a window object
* @return the layout of the window (from 'lv_layout_t')
*/
lv_layout_t lv_win_get_layout(lv_obj_t *win);
/**
* Get the scroll bar mode of a window
* @param win pointer to a window object
* @return the scroll bar mode of the window (from 'lv_sb_mode_t')
*/
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t *win);
/**
* Get width of the content area (page scrollable) of the window
* @param win pointer to a window object
* @return the width of the content area
*/
lv_coord_t lv_win_get_width(lv_obj_t * win);
/**
* Get a style of a window
* @param win pointer to a button object
@ -217,7 +239,7 @@ void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, uint16_t anim_time);
*/
static inline void lv_win_scroll_hor(lv_obj_t * win, lv_coord_t dist)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_win_ext_t * ext = (lv_win_ext_t *)lv_obj_get_ext_attr(win);
lv_page_scroll_hor(ext->page, dist);
}
/**
@ -227,7 +249,7 @@ static inline void lv_win_scroll_hor(lv_obj_t * win, lv_coord_t dist)
*/
static inline void lv_win_scroll_ver(lv_obj_t * win, lv_coord_t dist)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_win_ext_t * ext = (lv_win_ext_t *)lv_obj_get_ext_attr(win);
lv_page_scroll_ver(ext->page, dist);
}

View File

@ -36,6 +36,7 @@ typedef struct {
#if USE_LV_CONT != 0
lv_style_t *cont;
#endif
#if USE_LV_BTN != 0
struct {
lv_style_t *rel;
@ -46,6 +47,17 @@ typedef struct {
} btn;
#endif
#if USE_LV_IMGBTN != 0
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
} imgbtn;
#endif
#if USE_LV_LABEL != 0
struct {
lv_style_t *prim;
@ -94,6 +106,14 @@ typedef struct {
lv_style_t *gauge;
#endif
#if USE_LV_ARC != 0
lv_style_t *arc;
#endif
#if USE_LV_PRELOAD != 0
lv_style_t *preload;
#endif
#if USE_LV_SW != 0
struct {
lv_style_t *bg;
@ -107,6 +127,19 @@ typedef struct {
lv_style_t *chart;
#endif
#if USE_LV_CALENDAR != 0
struct {
lv_style_t *bg;
lv_style_t *header;
lv_style_t *header_pr;
lv_style_t *day_names;
lv_style_t *highlighted_days;
lv_style_t *inactive_days;
lv_style_t *week_box;
lv_style_t *today_box;
}calendar;
#endif
#if USE_LV_CB != 0
struct {
lv_style_t *bg;
@ -265,8 +298,10 @@ lv_theme_t * lv_theme_get_current(void);
#include "lv_theme_night.h"
#include "lv_theme_zen.h"
#include "lv_theme_mono.h"
#include "lv_theme_nemo.h"
#include "lv_theme_material.h"
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -379,6 +379,34 @@ static void gauge_init(void)
#endif
}
static void arc_init(void)
{
#if USE_LV_ARC != 0
static lv_style_t arc;
lv_style_copy(&arc, &def);
arc.line.width = 8;
arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
arc.line.rounded = 1;
/*For preloader*/
arc.body.border.width = 2;
arc.body.border.color = LV_COLOR_HEX3(0x555);
arc.body.padding.hor = 3;
arc.body.padding.ver = 3;
theme.arc = &arc;
#endif
}
static void preload_init(void)
{
#if USE_LV_PRELOAD != 0
theme.preload = theme.arc;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
@ -386,6 +414,46 @@ static void chart_init(void)
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR
static lv_style_t header;
static lv_style_t color_text;
static lv_style_t gray_text;
static lv_style_t today_box;
lv_style_copy(&header, &def);
header.body.radius = 0;
header.body.padding.hor = LV_DPI / 12;
header.body.padding.ver = LV_DPI / 14;
header.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 60);
header.body.grad_color = header.body.main_color;
header.body.border.opa = panel.body.border.opa;
header.body.border.width = panel.body.border.width;
header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
lv_style_copy(&today_box, &header);
today_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 70);
today_box.body.grad_color = today_box.body.main_color;
today_box.body.empty = 1;
lv_style_copy(&color_text, &def);
color_text.text.color = lv_color_hsv_to_rgb(_hue, 30, 80);
lv_style_copy(&gray_text, &def);
gray_text.text.color = lv_color_hsv_to_rgb(_hue, 10, 65);
theme.calendar.bg = &panel;
theme.calendar.header = &header;
theme.calendar.week_box = &header;
theme.calendar.today_box = &today_box;
theme.calendar.day_names = &color_text;
theme.calendar.highlighted_days = &color_text;
theme.calendar.inactive_days= &gray_text;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
@ -667,23 +735,23 @@ static void tabview_init(void)
static void win_init(void)
{
#if USE_LV_WIN != 0
static lv_style_t win_header;
static lv_style_t header;
lv_style_copy(&win_header, &def);
win_header.body.radius = 0;
win_header.body.padding.hor = LV_DPI / 12;
win_header.body.padding.ver = LV_DPI / 20;
win_header.body.main_color = lv_color_hsv_to_rgb(_hue, 20, 50);
win_header.body.grad_color = win_header.body.main_color;
win_header.body.border.opa = panel.body.border.opa;
win_header.body.border.width = panel.body.border.width;
win_header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
win_header.body.border.part = LV_BORDER_BOTTOM;
win_header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
lv_style_copy(&header, &def);
header.body.radius = 0;
header.body.padding.hor = LV_DPI / 12;
header.body.padding.ver = LV_DPI / 20;
header.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 60);
header.body.grad_color = header.body.main_color;
header.body.border.opa = panel.body.border.opa;
header.body.border.width = panel.body.border.width;
header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
header.body.border.part = LV_BORDER_BOTTOM;
header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
theme.win.bg = &bg;
theme.win.sb = &sb;
theme.win.header = &win_header;
theme.win.header = &header;
theme.win.content.bg = &lv_style_transp;
theme.win.content.scrl = &lv_style_transp;
theme.win.btn.rel = &btn_rel;
@ -727,7 +795,10 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
sw_init();
lmeter_init();
gauge_init();
arc_init();
preload_init();
chart_init();
calendar_init();
cb_init();
btnm_init();
kb_init();

View File

@ -77,6 +77,7 @@ static void basic_init(void)
sb.body.main_color = LV_COLOR_BLACK;
sb.body.grad_color = LV_COLOR_BLACK;
sb.body.opa = LV_OPA_40;
sb.body.padding.hor = LV_DPI / 25;
theme.bg = &bg;
theme.panel = &panel;
@ -288,7 +289,7 @@ static void lmeter_init(void)
lmeter.body.grad_color = lmeter.body.main_color;
lmeter.body.padding.hor = LV_DPI / 10; /*Scale line length*/
lmeter.line.color = LV_COLOR_HEX3(0x999);
lmeter.line.width = 3;
lmeter.line.width = 2;
theme.lmeter = &lmeter;
#endif
@ -313,15 +314,78 @@ static void gauge_init(void)
#endif
}
static void arc_init(void)
{
#if USE_LV_ARC != 0
static lv_style_t arc;
lv_style_copy(&arc, &def);
arc.line.width = 10;
arc.line.color = lv_color_hsv_to_rgb(_hue, 90, 90);
/*For prelaoder*/
arc.body.border.width = 10;
arc.body.border.color = lv_color_hsv_to_rgb(_hue, 30, 90);
arc.body.padding.hor = 0;
arc.body.padding.ver = 0;
theme.arc = &arc;
#endif
}
static void preload_init(void)
{
#if USE_LV_PRELOAD != 0
theme.preload = theme.arc;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = theme.panel;
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR
static lv_style_t ina_days;
lv_style_copy(&ina_days, &def);
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 70);
static lv_style_t high_days;
lv_style_copy(&high_days, &def);
high_days.text.color = lv_color_hsv_to_rgb(_hue, 80, 90);
static lv_style_t week_box;
lv_style_copy(&week_box, &def);
week_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 100);
week_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 100);
week_box.body.padding.ver = LV_DPI / 20;
week_box.body.padding.hor = theme.panel->body.padding.hor;
week_box.body.border.color = theme.panel->body.border.color;
week_box.body.border.width = theme.panel->body.border.width;
week_box.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
week_box.body.radius = 0;
static lv_style_t today_box;
lv_style_copy(&today_box, &def);
today_box.body.main_color = LV_COLOR_WHITE;
today_box.body.grad_color = LV_COLOR_WHITE;
today_box.body.padding.ver = LV_DPI / 20;
today_box.body.radius = 0;
theme.calendar.bg = theme.panel;
theme.calendar.header = &lv_style_transp;
theme.calendar.inactive_days = &ina_days;
theme.calendar.highlighted_days = &high_days;
theme.calendar.week_box = &week_box;
theme.calendar.today_box = &today_box;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
@ -723,6 +787,9 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
lmeter_init();
gauge_init();
chart_init();
arc_init();
preload_init();
calendar_init();
cb_init();
btnm_init();
kb_init();

View File

@ -244,12 +244,23 @@ static void gauge_init(void)
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &light_frame;
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR
static lv_style_t box;
lv_style_copy(&box, &light_plain);
box.body.padding.ver = LV_DPI / 20;
/*Can't handle highlighted dates in this theme*/
theme.calendar.week_box = &box;
theme.calendar.today_box = &box;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
@ -442,6 +453,7 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
lmeter_init();
gauge_init();
chart_init();
calendar_init();
cb_init();
btnm_init();
kb_init();

822
lv_themes/lv_theme_nemo.c Normal file
View File

@ -0,0 +1,822 @@
/**
* @file lv_theme_nemo.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_theme.h"
#if USE_LV_THEME_NEMO
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static uint16_t _hue;
static lv_font_t * _font;
static lv_font_t * _font;
static lv_font_t * _font;
static lv_theme_t theme;
static lv_style_t def;
static lv_style_t bg;
static lv_style_t panel; /*General fancy background (e.g. to chart or ta)*/
static lv_style_t sb;
static lv_style_t btn_rel, btn_pr, btn_trel, btn_tpr, btn_ina;
#if USE_LV_BAR
static lv_style_t bar_bg, bar_indic;
#endif
#if USE_LV_SLIDER
static lv_style_t slider_knob;
#endif
#if USE_LV_LMETER
static lv_style_t lmeter_bg;
#endif
#if USE_LV_DDLIST
static lv_style_t ddlist_bg, ddlist_sel;
#endif
#if USE_LV_BTNM
static lv_style_t btnm_bg, btnm_rel, btnm_pr, btnm_trel, btnm_ina;
#endif
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void basic_init(void)
{
/*Default*/
lv_style_copy(&def, &lv_style_plain);
def.body.opa = LV_OPA_COVER;
def.glass = 0;
def.body.empty = 0;
def.body.main_color = LV_COLOR_HEX3(0x222);
def.body.grad_color = LV_COLOR_HEX3(0x222);
def.body.radius = 0;
def.body.padding.hor = LV_DPI / 8;
def.body.padding.ver = LV_DPI / 8;
def.body.padding.inner = LV_DPI / 8;
def.body.border.color = LV_COLOR_SILVER;
def.body.border.width = 1;
def.body.border.opa = LV_OPA_COVER;
def.body.shadow.color = LV_COLOR_SILVER;
def.body.shadow.width = 0;
def.body.shadow.type = LV_SHADOW_FULL;
def.text.color = LV_COLOR_HEX3(0xDDD);
def.text.font = _font;
def.text.letter_space = 1;
def.text.line_space = 2;
def.image.color = LV_COLOR_HEX3(0xDDD);
def.image.intense = LV_OPA_TRANSP;
def.line.color = LV_COLOR_HEX3(0xDDD);
def.line.width = 1;
/*Background*/
lv_style_copy(&bg, &def);
bg.body.main_color = LV_COLOR_HEX3(0x005);
bg.body.grad_color = LV_COLOR_HEX3(0x045);
bg.body.border.width = 2;
bg.body.border.color = LV_COLOR_HEX3(0x666);
bg.body.shadow.color = LV_COLOR_SILVER;
/*Panel*/
lv_style_copy(&panel, &def);
panel.body.radius = LV_DPI / 10;
panel.body.main_color = LV_COLOR_HEX3(0x500);
panel.body.grad_color = LV_COLOR_HEX3(0x505);
panel.body.border.color = LV_COLOR_HEX3(0xccc);
panel.body.border.width = 2;
panel.body.border.opa = LV_OPA_60;
panel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
panel.line.color = lv_color_hsv_to_rgb(_hue, 20, 70);
/*Scrollbar*/
lv_style_copy(&sb, &def);
sb.body.opa = LV_OPA_50;
sb.body.radius = LV_RADIUS_CIRCLE;
sb.body.border.color = LV_COLOR_SILVER;
sb.body.border.opa = LV_OPA_40;
sb.body.border.width = 1;
sb.body.main_color = lv_color_hsv_to_rgb(_hue, 33, 92);
sb.body.grad_color = lv_color_hsv_to_rgb(_hue, 33, 92);
sb.body.padding.hor = 1;
sb.body.padding.ver = 1;
sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/
theme.bg = &bg;
theme.panel = &panel;
}
static void btn_init(void)
{
#if USE_LV_BTN != 0
lv_style_copy(&btn_rel, &def);
btn_rel.glass = 0;
btn_rel.body.empty = 1;
btn_rel.body.radius = LV_RADIUS_CIRCLE;
btn_rel.body.border.width = 2;
btn_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90);
btn_rel.body.border.opa = LV_OPA_80;
btn_rel.body.padding.hor = LV_DPI / 4;
btn_rel.body.padding.ver = LV_DPI / 6;
btn_rel.body.padding.inner = LV_DPI / 10;
btn_rel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
btn_rel.text.font = _font;
lv_style_copy(&btn_pr, &btn_rel);
btn_pr.body.opa = LV_OPA_COVER;
btn_pr.body.empty = 0;
btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50);
btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50);
btn_pr.body.border.opa = LV_OPA_60;
btn_pr.text.font = _font;
btn_pr.text.color = lv_color_hsv_to_rgb(_hue, 10, 100);
lv_style_copy(&btn_trel, &btn_pr);
btn_trel.body.opa = LV_OPA_COVER;
btn_trel.body.empty = 0;
btn_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 60);
btn_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 60);
btn_trel.body.border.opa = LV_OPA_60;
btn_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 90);
btn_trel.text.font = _font;
btn_trel.text.color = lv_color_hsv_to_rgb(_hue, 0, 100);
lv_style_copy(&btn_tpr, &btn_trel);
btn_tpr.body.opa = LV_OPA_COVER;
btn_tpr.body.empty = 0;
btn_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50);
btn_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50);
btn_tpr.body.border.opa = LV_OPA_60;
btn_tpr.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70);
btn_tpr.text.font = _font;
btn_tpr.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_ina, &btn_rel);
btn_ina.body.border.opa = LV_OPA_60;
btn_ina.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 50);
btn_ina.text.font = _font;
btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
theme.btn.rel = &btn_rel;
theme.btn.pr = &btn_pr;
theme.btn.tgl_rel = &btn_trel;
theme.btn.tgl_pr = &btn_tpr;
theme.btn.ina = &btn_ina;
#endif
}
static void label_init(void)
{
#if USE_LV_LABEL != 0
static lv_style_t label_prim, label_sec, label_hint;
lv_style_copy(&label_prim, &def);
label_prim.text.font = _font;
label_prim.text.color = lv_color_hsv_to_rgb(_hue, 5, 96);
label_prim.body.empty = 1;
label_prim.body.border.width = 0;
lv_style_copy(&label_sec, &label_prim);
label_sec.text.color = lv_color_hsv_to_rgb(_hue, 40, 85);
lv_style_copy(&label_hint, &label_prim);
label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
theme.label.prim = &label_prim;
theme.label.sec = &label_sec;
theme.label.hint = &label_hint;
#endif
}
static void bar_init(void)
{
#if USE_LV_BAR
lv_style_copy(&bar_bg, &def);
bar_bg.body.opa = LV_OPA_30;
bar_bg.body.radius = LV_RADIUS_CIRCLE;
bar_bg.body.main_color = LV_COLOR_WHITE;
bar_bg.body.grad_color = LV_COLOR_SILVER;
bar_bg.body.border.width = 2;
bar_bg.body.border.color = LV_COLOR_SILVER;
bar_bg.body.border.opa = LV_OPA_20;
bar_bg.body.padding.hor = 0;
bar_bg.body.padding.ver = LV_DPI / 10;
bar_bg.body.padding.inner = 0;
lv_style_copy(&bar_indic, &def);
bar_indic.body.radius = LV_RADIUS_CIRCLE;
bar_indic.body.border.width = 2;
bar_indic.body.border.color = LV_COLOR_SILVER;
bar_indic.body.border.opa = LV_OPA_70;
bar_indic.body.padding.hor = 0;
bar_indic.body.padding.ver = 0;
bar_indic.body.shadow.width = LV_DPI / 20;
bar_indic.body.shadow.color = lv_color_hsv_to_rgb(_hue, 20, 90);
bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
bar_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80);
theme.bar.bg = &bar_bg;
theme.bar.indic = &bar_indic;
#endif
}
static void img_init(void)
{
#if USE_LV_IMG != 0
static lv_style_t img_light, img_dark;
lv_style_copy(&img_light, &def);
img_light.image.color = lv_color_hsv_to_rgb(_hue, 15, 85);
img_light.image.intense = LV_OPA_80;
lv_style_copy(&img_dark, &def);
img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65);
img_light.image.intense = LV_OPA_80;
theme.img.light = &img_light;
theme.img.dark = &img_dark;
#endif
}
static void line_init(void)
{
#if USE_LV_LINE != 0
static lv_style_t line_decor;
lv_style_copy(&line_decor, &def);
line_decor.line.color = lv_color_hsv_to_rgb(_hue, 50, 50);
line_decor.line.width = 1;
theme.line.decor = &line_decor;
#endif
}
static void led_init(void)
{
#if USE_LV_LED != 0
static lv_style_t led;
lv_style_copy(&led, &lv_style_pretty_color);
led.body.shadow.width = LV_DPI / 10;
led.body.radius = LV_RADIUS_CIRCLE;
led.body.border.width= LV_DPI / 30;
led.body.border.opa = LV_OPA_30;
led.body.main_color = lv_color_hsv_to_rgb(_hue, 100, 100);
led.body.grad_color = lv_color_hsv_to_rgb(_hue, 100, 40);
led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100);
theme.led = &led;
#endif
}
static void slider_init(void)
{
#if USE_LV_SLIDER != 0
lv_style_copy(&slider_knob, &def);
slider_knob.body.opa = LV_OPA_60;
slider_knob.body.radius = LV_RADIUS_CIRCLE;
slider_knob.body.main_color = LV_COLOR_PURPLE;
slider_knob.body.grad_color = LV_COLOR_SILVER;
slider_knob.body.border.width = 2;
slider_knob.body.border.color = LV_COLOR_ORANGE;
slider_knob.body.border.opa = LV_OPA_50;
theme.slider.bg = &bar_bg;
theme.slider.indic = &bar_indic;
theme.slider.knob = &slider_knob;
#endif
}
static void sw_init(void)
{
#if USE_LV_SW != 0
static lv_style_t sw_bg, sw_indic, sw_knob;
lv_style_copy(&sw_bg, &bar_bg);
sw_bg.body.opa = LV_OPA_COVER;
sw_bg.body.padding.ver = -2 ;
sw_bg.body.padding.hor = -2 ;
sw_bg.body.main_color = LV_COLOR_HEX3(0x666);
sw_bg.body.grad_color = LV_COLOR_HEX3(0x999);
sw_bg.body.border.width = 2;
sw_bg.body.border.opa = LV_OPA_50;
lv_style_copy(&sw_indic, &bar_indic);
sw_indic.body.shadow .width = LV_DPI / 20;
sw_indic.body.padding.ver = 0;
sw_indic.body.padding.hor = 0;
lv_style_copy(&sw_knob, &slider_knob);
sw_knob.body.opa = LV_OPA_80;
theme.sw.bg = &sw_bg;
theme.sw.indic = &sw_indic;
theme.sw.knob_off = &sw_knob;
theme.sw.knob_on = &sw_knob;
#endif
}
static void lmeter_init(void)
{
#if USE_LV_LMETER != 0
lv_style_copy(&lmeter_bg, &def);
lmeter_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 70);
lmeter_bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 80);
lmeter_bg.body.padding.hor = LV_DPI / 8; /*Scale line length*/
lmeter_bg.line.color = LV_COLOR_HEX3(0x500);
lmeter_bg.line.width = 2;
theme.lmeter = &lmeter_bg;
#endif
}
static void gauge_init(void)
{
#if USE_LV_GAUGE != 0
static lv_style_t gauge_bg;
lv_style_copy(&gauge_bg, &def);
gauge_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 20, 100);
gauge_bg.body.grad_color = gauge_bg.body.main_color;
gauge_bg.body.padding.hor = LV_DPI / 16; /*Scale line length*/
gauge_bg.body.padding.ver = LV_DPI / 20; /*Needle center size*/
gauge_bg.body.padding.inner = LV_DPI / 12; /*Label - scale distance*/
gauge_bg.body.border.color = LV_COLOR_HEX3(0x500);
gauge_bg.line.color = lv_color_hsv_to_rgb(_hue, 80, 75);
gauge_bg.line.width = 2;
gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
gauge_bg.text.font = _font;
theme.gauge = &gauge_bg;
#endif
}
static void arc_init(void)
{
#if USE_LV_ARC != 0
static lv_style_t arc;
lv_style_copy(&arc, &def);
arc.line.width = 10;
arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
arc.line.rounded = 1;
/*For preloader*/
arc.body.border.width = 0;
theme.arc = &arc;
#endif
}
static void preload_init(void)
{
#if USE_LV_PRELOAD != 0
theme.preload = theme.arc;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &panel;
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR != 0
static lv_style_t ina_days;
lv_style_copy(&ina_days, &def);
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 50);
static lv_style_t high_days;
lv_style_copy(&high_days, &def);
high_days.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
static lv_style_t week_box;
lv_style_copy(&week_box, &def);
week_box.body.empty = 1;
week_box.body.border.color = theme.panel->body.border.color;
week_box.body.padding.ver = LV_DPI / 20;
static lv_style_t today_box;
lv_style_copy(&today_box, &def);
today_box.body.main_color = LV_COLOR_WHITE;
today_box.body.grad_color = LV_COLOR_WHITE;
today_box.body.padding.ver = LV_DPI / 20;
today_box.body.radius = 0;
theme.calendar.bg = theme.panel;
theme.calendar.header = theme.label.prim;
theme.calendar.inactive_days = theme.label.hint;
theme.calendar.highlighted_days = theme.label.sec;
theme.calendar.week_box = &week_box;
theme.calendar.today_box = &week_box;
theme.calendar.header_pr= theme.label.prim;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
static lv_style_t cb_bg, cb_rel, cb_pr, cb_trel, cb_tpr, cb_ina;
lv_style_copy(&cb_rel, &bg);
cb_rel.body.radius = LV_DPI / 20;
cb_rel.body.border.width = 1;
cb_rel.body.border.color = LV_COLOR_ORANGE;
cb_rel.body.main_color = LV_COLOR_PURPLE;
cb_rel.body.grad_color = LV_COLOR_SILVER;
lv_style_copy(&cb_bg, &bg);
cb_bg.body.empty = 1;
cb_bg.body.border.width = 0;
cb_bg.body.padding.inner = LV_DPI / 8;
cb_bg.body.padding.hor = 0;
cb_bg.body.padding.ver = 0;
cb_bg.text.font = _font;
lv_style_copy(&cb_pr, &cb_rel);
cb_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 90);
cb_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 82);
lv_style_copy(&cb_trel, &cb_rel);
cb_trel.body.border.width = 4;
cb_trel.body.border.color = LV_COLOR_WHITE;
cb_trel.body.border.opa = LV_OPA_60;
cb_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 82);
cb_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 62);
lv_style_copy(&cb_tpr, &cb_trel);
cb_tpr.body.border.color = LV_COLOR_SILVER;
cb_tpr.body.border.opa = LV_OPA_70;
cb_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 72);
cb_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 52);
lv_style_copy(&cb_ina, &cb_trel);
cb_ina.body.border.width = 1;
cb_ina.body.border.color = LV_COLOR_GRAY;
cb_ina.body.main_color = LV_COLOR_PURPLE;
cb_ina.body.grad_color = LV_COLOR_SILVER;
theme.cb.bg = &cb_bg;
theme.cb.box.rel = &cb_rel;
theme.cb.box.pr = &cb_pr;
theme.cb.box.tgl_rel = &cb_trel;
theme.cb.box.tgl_pr = &cb_tpr;
theme.cb.box.ina = &cb_ina;
#endif
}
static void btnm_init(void)
{
#if USE_LV_BTNM
lv_style_copy(&btnm_bg, &lv_style_transp_tight);
btnm_bg.body.border.width = 1;
btnm_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 80);
btnm_bg.body.border.opa = LV_OPA_COVER;
btnm_bg.body.radius = LV_DPI / 8;
lv_style_copy(&btnm_rel, &lv_style_plain);
btnm_rel.body.empty = 1;
btnm_rel.body.radius = LV_DPI / 8;
btnm_rel.text.color = lv_color_hsv_to_rgb(_hue, 60, 80);
btnm_rel.text.font = _font;
lv_style_copy(&btnm_pr, &lv_style_plain);
btnm_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.radius = LV_DPI / 8;
btnm_pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 40);
btnm_pr.text.font = _font;
lv_style_copy(&btnm_trel, &btnm_rel);
btnm_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 80);
btnm_trel.body.border.width = 3;
lv_style_copy(&btnm_ina, &btnm_rel);
btnm_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 60);
theme.btnm.bg = &btnm_bg;
theme.btnm.btn.rel = &btnm_rel;
theme.btnm.btn.pr = &btnm_pr;
theme.btnm.btn.tgl_rel = &btnm_trel;
theme.btnm.btn.tgl_pr = &btnm_pr;
theme.btnm.btn.ina = &btnm_ina;
#endif
}
static void kb_init(void)
{
#if USE_LV_KB
theme.kb.bg = &btnm_bg;
theme.kb.btn.rel = &btnm_rel;
theme.kb.btn.pr = &btnm_pr;
theme.kb.btn.tgl_rel = &btnm_trel;
theme.kb.btn.tgl_pr = &btnm_pr;
theme.kb.btn.ina = &btnm_ina;
#endif
}
static void mbox_init(void)
{
#if USE_LV_MBOX
static lv_style_t mbox_bg;
lv_style_copy(&mbox_bg, &panel);
mbox_bg.body.shadow.width = LV_DPI / 12;
theme.mbox.bg = &mbox_bg;
theme.mbox.btn.bg = &lv_style_transp;
theme.mbox.btn.rel = &btn_trel;
theme.mbox.btn.pr = &btn_tpr;
#endif
}
static void page_init(void)
{
#if USE_LV_PAGE
theme.page.bg = &panel;
theme.page.scrl = &lv_style_transp_fit;
theme.page.sb = &sb;
#endif
}
static void ta_init(void)
{
#if USE_LV_TA
theme.ta.area = &panel;
theme.ta.oneline = &panel;
theme.ta.cursor = NULL;
theme.ta.sb = &sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
static lv_style_t list_bg, list_rel, list_pr, list_trel, list_tpr, list_ina;
lv_style_copy(&list_rel, &def);
list_rel.body.empty = 1;
list_rel.body.border.width = 1;
list_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 50, 85);
list_rel.body.border.opa = LV_OPA_COVER;
list_rel.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
list_rel.text.font = _font;
lv_style_copy(&list_pr, &list_rel);
list_pr.body.empty = 0;
list_pr.body.opa = LV_OPA_COVER;
list_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 34, 41);
list_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 34, 41);
list_pr.text.color = lv_color_hsv_to_rgb(_hue, 7, 96);
lv_style_copy(&list_trel, &list_rel);
lv_style_copy(&list_tpr, &list_pr);
lv_style_copy(&list_ina, &def);
lv_style_copy(&list_bg, &list_rel);
list_bg.body.padding.hor = 0;
list_bg.body.padding.ver = 0;
theme.list.sb = &sb;
theme.list.bg = &list_bg;
theme.list.scrl = &lv_style_transp_tight;
theme.list.btn.rel = &list_rel;
theme.list.btn.pr = &list_pr;
theme.list.btn.tgl_rel = &list_trel;
theme.list.btn.tgl_pr = &list_tpr;
theme.list.btn.ina = &list_ina;
#endif
}
static void ddlist_init(void)
{
#if USE_LV_DDLIST != 0
lv_style_copy(&ddlist_bg, &panel);
ddlist_bg.text.line_space = LV_DPI / 8;
ddlist_bg.body.padding.hor = LV_DPI / 6;
ddlist_bg.body.padding.ver = LV_DPI / 6;
lv_style_copy(&ddlist_sel, &panel);
ddlist_sel.body.main_color = lv_color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.grad_color = lv_color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.opa = LV_OPA_COVER;
ddlist_sel.body.radius = 0;
theme.ddlist.bg = &ddlist_bg;
theme.ddlist.sel = &ddlist_sel;
theme.ddlist.sb = &sb;
#endif
}
static void roller_init(void)
{
#if USE_LV_ROLLER != 0
static lv_style_t roller_bg, roller_sel;
lv_style_copy(&roller_bg, &ddlist_bg);
roller_bg.text.line_space = LV_DPI / 6;
roller_bg.body.radius = LV_DPI / 20;
roller_bg.body.main_color = LV_COLOR_HEX3(0x500);
roller_bg.body.grad_color = LV_COLOR_HEX3(0x005);
roller_bg.body.border.opa = LV_OPA_30;
roller_bg.text.opa = LV_OPA_70;
roller_bg.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
roller_bg.body.shadow.width = 0;
lv_style_copy(&roller_sel, &panel);
roller_sel.body.empty = 1;
roller_sel.body.radius = 0;
roller_sel.text.opa = LV_OPA_COVER;
roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95);
theme.roller.bg = &roller_bg;
theme.roller.sel = &roller_sel;
#endif
}
static void tabview_init(void)
{
#if USE_LV_TABVIEW != 0
static lv_style_t tab_rel, tab_pr, tab_trel, tab_tpr, tab_indic;
lv_style_copy(&tab_rel, &def);
tab_rel.body.main_color = LV_COLOR_HEX3(0x500);
tab_rel.body.grad_color = LV_COLOR_HEX3(0x005);
tab_rel.body.padding.hor = 0;
tab_rel.body.padding.ver = LV_DPI / 6;
tab_rel.body.padding.inner = 0;
tab_rel.body.border.width = 1;
tab_rel.body.border.color = LV_COLOR_SILVER;
tab_rel.body.border.opa = LV_OPA_40;
tab_rel.text.color = LV_COLOR_HEX3(0xDDD);
tab_rel.text.font = _font;
lv_style_copy(&tab_pr, &tab_rel);
tab_pr.body.main_color = LV_COLOR_HEX3(0x005);
tab_pr.body.grad_color = LV_COLOR_HEX3(0x500);
lv_style_copy(&tab_trel, &def);
tab_trel.body.empty = 1;
tab_trel.body.padding.hor = 0;
tab_trel.body.padding.ver = LV_DPI / 6;
tab_trel.body.padding.inner = 0;
tab_trel.body.border.width = 1;
tab_trel.body.border.color = LV_COLOR_SILVER;
tab_trel.body.border.opa = LV_OPA_40;
tab_trel.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
tab_trel.text.font = _font;
lv_style_copy(&tab_tpr, &def);
tab_tpr.body.main_color = LV_COLOR_GRAY;
tab_tpr.body.grad_color = LV_COLOR_GRAY;
tab_tpr.body.padding.hor = 0;
tab_tpr.body.padding.ver = LV_DPI / 6;
tab_tpr.body.padding.inner = 0;
tab_tpr.body.border.width = 1;
tab_tpr.body.border.color = LV_COLOR_SILVER;
tab_tpr.body.border.opa = LV_OPA_40;
tab_tpr.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
tab_tpr.text.font = _font;
lv_style_copy(&tab_indic, &def);
tab_indic.body.border.width = 0;
tab_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.padding.inner = LV_DPI / 10; /*Indicator height*/
theme.tabview.bg = &bg;
theme.tabview.indic = &tab_indic;
theme.tabview.btn.bg = &lv_style_transp_tight;
theme.tabview.btn.rel = &tab_rel;
theme.tabview.btn.pr = &tab_pr;
theme.tabview.btn.tgl_rel = &tab_trel;
theme.tabview.btn.tgl_pr = &tab_tpr;
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
static lv_style_t win_header;
lv_style_copy(&win_header, &panel);
win_header.body.radius = 0;
win_header.body.padding.hor = LV_DPI / 12;
win_header.body.padding.ver = LV_DPI / 20;
win_header.body.border.opa = panel.body.border.opa;
win_header.body.border.width = panel.body.border.width;
win_header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
win_header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
theme.win.bg = &bg;
theme.win.sb = &sb;
theme.win.header = &win_header;
theme.win.content.bg = &lv_style_transp;
theme.win.content.scrl = &lv_style_transp;
theme.win.btn.rel = &btn_rel;
theme.win.btn.pr = &btn_pr;
#endif
}
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the nemo theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t *font)
{
if(font == NULL) font = LV_FONT_DEFAULT;
_hue = hue;
_font = font;
/*For backward compatibility initialize all theme elements with a default style */
uint16_t i;
lv_style_t **style_p = (lv_style_t**) &theme;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
*style_p = &def;
style_p++;
}
basic_init();
btn_init();
label_init();
bar_init();
img_init();
line_init();
led_init();
slider_init();
sw_init();
lmeter_init();
gauge_init();
arc_init();
preload_init();
chart_init();
calendar_init();
cb_init();
btnm_init();
kb_init();
mbox_init();
page_init();
ta_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
win_init();
return &theme;
}
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_nemo(void)
{
return &theme;
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif

56
lv_themes/lv_theme_nemo.h Normal file
View File

@ -0,0 +1,56 @@
/**
* @file lv_theme_nemo.h
*
*/
#ifndef LV_THEME_NEMO_H
#define LV_THEME_NEMO_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_THEME_NEMO
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the material theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t *font);
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_nemo(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_THEME_NEMO_H*/

View File

@ -160,16 +160,6 @@ static void label_init(void)
#endif
}
static void img_init(void)
{
#if USE_LV_IMG != 0
theme.img.light = &def;
theme.img.dark = &def;
#endif
}
static void line_init(void)
{
#if USE_LV_LINE != 0
@ -197,6 +187,16 @@ static void led_init(void)
#endif
}
static void img_init(void)
{
#if USE_LV_IMG != 0
theme.img.light = &def;
theme.img.dark = &def;
#endif
}
static void bar_init(void)
{
#if USE_LV_BAR
@ -278,14 +278,99 @@ static void gauge_init(void)
#endif
}
static void arc_init(void)
{
#if USE_LV_ARC != 0
static lv_style_t arc;
lv_style_copy(&arc, &def);
arc.line.width = 8;
arc.line.color = lv_color_hsv_to_rgb(_hue, 80, 70);
arc.line.rounded = 1;
/*For preloader*/
arc.body.border.width = 7;
arc.body.border.color = lv_color_hsv_to_rgb(_hue, 11, 48);
arc.body.padding.hor = 1;
arc.body.padding.ver = 1;
theme.arc = &arc;
#endif
}
static void preload_init(void)
{
#if USE_LV_PRELOAD != 0
theme.preload = theme.arc;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &panel;
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR
static lv_style_t cal_bg;
lv_style_copy(&cal_bg, &bg);
cal_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 40);
cal_bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 40);
cal_bg.body.border.color = LV_COLOR_HEX3(0x333);
cal_bg.body.border.width = 1;
cal_bg.body.radius = LV_DPI / 20;
cal_bg.body.padding.hor = LV_DPI/10;
cal_bg.body.padding.ver = LV_DPI/10;
static lv_style_t cal_header;
lv_style_copy(&cal_header, &bg);
cal_header.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 20);
cal_header.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 20);
cal_header.body.radius = 0;
cal_header.body.border.width = 1;
cal_header.body.border.color = LV_COLOR_HEX3(0x333);
cal_header.body.padding.hor = LV_DPI/10;
cal_header.body.padding.ver = LV_DPI/10;
static lv_style_t week_box;
lv_style_copy(&week_box, &panel);
week_box.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 45);
week_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 30, 45);
week_box.body.radius = LV_DPI / 20;
week_box.body.border.width = 1;
week_box.body.padding.hor = LV_DPI / 20;
week_box.body.padding.ver = LV_DPI / 25;
static lv_style_t today_box;
lv_style_copy(&today_box, &week_box);
today_box.body.main_color = lv_color_hsv_to_rgb(_hue, 80, 70);
today_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 70);
today_box.body.radius = LV_DPI / 20;
today_box.body.padding.hor = LV_DPI / 14;
today_box.body.padding.ver = LV_DPI / 14;
static lv_style_t highlighted_days;
lv_style_copy(&highlighted_days, &bg);
highlighted_days.text.color = lv_color_hsv_to_rgb(_hue, 40, 80);
static lv_style_t ina_days;
lv_style_copy(&ina_days, &bg);
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 60);
theme.calendar.bg = &cal_bg;
theme.calendar.header = &cal_header;
theme.calendar.week_box = &week_box;
theme.calendar.today_box = &today_box;
theme.calendar.highlighted_days = &highlighted_days;
theme.calendar.day_names = &cal_bg;
theme.calendar.inactive_days = &ina_days;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
@ -610,7 +695,10 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
sw_init();
lmeter_init();
gauge_init();
arc_init();
preload_init();
chart_init();
calendar_init();
cb_init();
btnm_init();
kb_init();

View File

@ -74,6 +74,16 @@ static void btn_init(void)
#endif
}
static void imgbtn_init(void)
{
#if USE_LV_IMGBTN != 0
theme.imgbtn.rel = &def;
theme.imgbtn.pr = &def;
theme.imgbtn.tgl_rel = &def;
theme.imgbtn.tgl_pr = &def;
theme.imgbtn.ina = &def;
#endif
}
static void label_init(void)
{
@ -166,15 +176,47 @@ static void gauge_init(void)
#endif
}
static void arc_init(void)
{
#if USE_LV_ARC != 0
theme.arc = &def;
#endif
}
static void preload_init(void)
{
#if USE_LV_PRELOAD != 0
theme.preload = &def;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &def;
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR
theme.calendar.bg = theme.panel;
theme.calendar.header = &def;
theme.calendar.inactive_days = &def;
theme.calendar.highlighted_days = &def;
theme.calendar.week_box = &def;
theme.calendar.today_box = &def;
theme.calendar.header_pr = &def;
theme.calendar.day_names = &def;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
@ -352,6 +394,7 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
basic_init();
cont_init();
btn_init();
imgbtn_init();
label_init();
img_init();
line_init();
@ -361,6 +404,8 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
sw_init();
lmeter_init();
gauge_init();
arc_init();
preload_init();
chart_init();
cb_init();
btnm_init();

View File

@ -128,7 +128,6 @@ static void btn_init(void)
#endif
}
static void label_init(void)
{
#if USE_LV_LABEL != 0
@ -293,15 +292,71 @@ static void gauge_init(void)
#endif
}
static void arc_init(void)
{
#if USE_LV_ARC != 0
static lv_style_t arc;
lv_style_copy(&arc, &def);
arc.line.width = 10;
arc.line.color = lv_color_hsv_to_rgb(_hue, 40, 90);
arc.line.rounded = 1;
/*For preloader*/
arc.body.border.width = 0;
theme.arc = &arc;
#endif
}
static void preload_init(void)
{
#if USE_LV_PRELOAD != 0
theme.preload = theme.arc;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = theme.panel;
#endif
}
static void calendar_init(void)
{
#if USE_LV_CALENDAR != 0
static lv_style_t ina_days;
lv_style_copy(&ina_days, &def);
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 70);
static lv_style_t high_days;
lv_style_copy(&high_days, &def);
high_days.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
static lv_style_t week_box;
lv_style_copy(&week_box, &def);
week_box.body.empty = 1;
week_box.body.border.color = theme.panel->body.border.color;
week_box.body.padding.ver = LV_DPI / 20;
static lv_style_t today_box;
lv_style_copy(&today_box, &def);
today_box.body.main_color = LV_COLOR_WHITE;
today_box.body.grad_color = LV_COLOR_WHITE;
today_box.body.padding.ver = LV_DPI / 20;
today_box.body.radius = 0;
theme.calendar.bg = theme.panel;
theme.calendar.header = &lv_style_transp;
theme.calendar.inactive_days = &ina_days;
theme.calendar.highlighted_days = &high_days;
theme.calendar.week_box = &week_box;
theme.calendar.today_box = &week_box;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
@ -703,7 +758,10 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
sw_init();
lmeter_init();
gauge_init();
arc_init();
preload_init();
chart_init();
calendar_init();
cb_init();
btnm_init();
kb_init();

View File

@ -5,9 +5,9 @@ CSRCS += lv_theme_night.c
CSRCS += lv_theme_templ.c
CSRCS += lv_theme_zen.c
CSRCS += lv_theme_material.c
CSRCS += lv_theme_nemo.c
CSRCS += lv_theme_mono.c
DEPPATH += --dep-path lvgl/lv_themes
VPATH += :lvgl/lv_themes