multi-disp: refresh multiple displays

This commit is contained in:
Gabor Kiss-Vamosi
2019-02-12 12:21:34 +01:00
27 changed files with 288 additions and 345 deletions

2
.github/stale.yml vendored
View File

@@ -7,7 +7,7 @@ exemptLabels:
- architecture
- pinned
# Label to use when marking an issue as stale
# staleLabel:
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue or pull request has been automatically marked as stale because it has not had

View File

@@ -1,9 +1,9 @@
<h1 align="center"> LittlevGL - Open-source Embedded GUI Library</h1>
<p align="center">
<img src="https://img.shields.io/badge/licence-MIT-blue.svg">
<img src="https://img.shields.io/badge/version-v5.2-blue.svg">
<a href="https://github.com/littlevgl/lvgl/blob/master/LICENCE.txt"><img src="https://img.shields.io/badge/licence-MIT-blue.svg"></a>
<a href="https://github.com/littlevgl/lvgl/releases/tag/v5.3"><img src="https://img.shields.io/badge/version-5.3-blue.svg"></a>
<br>
<img src="https://littlevgl.com/github/cover3.gif">
<img src="https://littlevgl.com/github/cover_ori_reduced_2.gif">
</p>
<p align="center">
@@ -62,7 +62,7 @@ The easiest way to get started with LittlevGL is to run it in a simulator on you
Choose a project with your favourite IDE:
| Eclipse | CodeBlock | Visual Studio | PlatfomIO | Qt Creator |
| Eclipse | CodeBlock | Visual Studio | PlatformIO | Qt Creator |
|-------------|----------- |---------------|-----------|------------|
| [![Eclipse](https://littlevgl.com/logo/ide/eclipse.jpg)](https://github.com/littlevgl/pc_simulator_sdl_eclipse) | [![CodeBlocks](https://littlevgl.com/logo/ide/codeblocks.jpg)](https://github.com/littlevgl/pc_simulator_win_codeblocks) | [![VisualStudio](https://littlevgl.com/logo/ide/visualstudio.jpg)](https://github.com/littlevgl/visual_studio_2017_sdl_x64) | [![PlatformIO](https://littlevgl.com/logo/ide/platformio.jpg)](https://github.com/littlevgl/pc_simulator_sdl_platformio) | [![QtCreator](https://littlevgl.com/logo/ide/qtcreator.jpg)](https://blog.littlevgl.com/2019-01-03/qt-creator) |
| Cross-platform<br>with SDL | Native Windows | Cross-platform<br>with SDL | Cross-platform<br>with SDL | Cross-platform<br>with SDL |
@@ -105,20 +105,20 @@ bool touchpad_read(lv_indev_data_t * data)
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
/*Save the state and save the pressed cooridnate*/
/*Save the state and save the pressed coordinate*/
data->state = touchpad_is_pressed() ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
if(data->state == LV_INDEV_STATE_PR) touchpad_get_xy(&last_x, &last_y);
/*Set the coordinates (if released use the last pressed cooridantes)*/
/*Set the coordinates (if released use the last pressed coordinates)*/
data->point.x = last_x;
data->point.y = last_y;
return false; /*Return `false` because we are not buffering and no more data to read*/
}
```
6. Call `lv_task_handler()` periodically every few milliseconds.
6. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in Timer interrupt or in an Operation system task.
For a detailed description check the [Online documatation](https://docs.littlevgl.com/#Porting) or the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
### Code examples
@@ -154,15 +154,15 @@ style_btn_rel.body.radius = LV_RADIUS_CIRCLE;
style_btn_rel.text.color = LV_COLOR_HEX3(0xDEF);
static lv_style_t style_btn_pr; /*A variable to store the pressed style*/
lv_style_copy(&style_btn_pr, &style_btn_rel); /*Initialize from a built-in style*/
lv_style_copy(&style_btn_pr, &style_btn_rel); /*Initialize from the released style*/
style_btn_pr.body.border.color = LV_COLOR_HEX3(0x46B);
style_btn_pr.body.main_color = LV_COLOR_HEX3(0x8BD);
style_btn_pr.body.grad_color = LV_COLOR_HEX3(0x24A);
style_btn_pr.body.shadow.width = 2;
style_btn_pr.text.color = LV_COLOR_HEX3(0xBCD);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel); /*Set the buton's released style*/
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &style_btn_pr); /*Set the buton's pressed style*/
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel); /*Set the button's released style*/
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &style_btn_pr); /*Set the button's pressed style*/
```
![Simple button with LittelvGL](https://littlevgl.com/github/btn2.gif)

View File

@@ -40,7 +40,8 @@
#endif
#endif /*LV_MEM_CUSTOM*/
/* Garbage Collector settings. */
/* Garbage Collector settings
* Used if lvgl is binded to higher language and the memory is managed by that language */
#ifndef LV_ENABLE_GC
#define LV_ENABLE_GC 0
#endif
@@ -89,7 +90,7 @@
*----------------*/
/* VDB (Virtual Display Buffer) is an internal graphics buffer.
* To images will be drawn into this buffer first and then
* The GUI will be drawn into this buffer first and then
* the buffer will be passed to your `disp_drv.disp_flush` function to
* copy it to your frame buffer.
* VDB is required for: buffered drawing, opacity, anti-aliasing and shadows
@@ -115,7 +116,7 @@
#define LV_VDB_ADR 0
#endif
/* Use two Virtual Display buffers (VDB) parallelize rendering and flushing (optional)
/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing
* The flushing should use DMA to write the frame buffer in the background */
#ifndef LV_VDB_DOUBLE
#define LV_VDB_DOUBLE 0
@@ -165,7 +166,7 @@
/*Color settings*/
#ifndef LV_COLOR_DEPTH
#define LV_COLOR_DEPTH 32 /*Color depth: 1/8/16/32*/
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/
#endif
#ifndef LV_COLOR_16_SWAP
#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)*/
@@ -224,6 +225,9 @@
#ifndef LV_ATTRIBUTE_TASK_HANDLER
#define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */
#endif
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN /* With size optimization (-Os) the compiler might not align data to 4 or 8 byte boundary. This alignment will be explicitly applied where needed.*/
#endif
#ifndef LV_COMPILER_VLA_SUPPORTED
#define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/
#endif
@@ -237,7 +241,7 @@
#endif
#if LV_TICK_CUSTOM == 1
#ifndef LV_TICK_CUSTOM_INCLUDE
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_INCLUDE "sonething.h" /*Header for the sys time function*/
#endif
#ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
@@ -262,7 +266,7 @@
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
#ifndef LV_LOG_PRINTF
# define LV_LOG_PRINTF 1
# define LV_LOG_PRINTF 0
#endif
#endif /*USE_LV_LOG*/
@@ -386,7 +390,7 @@
#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/
#endif
#ifndef LV_OBJ_REALIGN
#define LV_OBJ_REALIGN 0 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
#define LV_OBJ_REALIGN 1 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
#endif
/*==================

View File

@@ -107,7 +107,7 @@
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%] (must be > 0). Greater value means faster slow-down */
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
@@ -136,13 +136,14 @@
/*Compiler settings*/
#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */
#define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */
#define LV_ATTRIBUTE_MEM_ALIGN /* With size optimization (-Os) the compiler might not align data to 4 or 8 byte boundary. This alignment will be explicitly applied where needed.*/
#define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/
#define LV_COMPILER_NON_CONST_INIT_SUPPORTED 1 /* 1: Initialization with non constant values are supported */
/*HAL settings*/
#define LV_TICK_CUSTOM 0 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */
#if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "sonething.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif /*LV_TICK_CUSTOM*/

View File

@@ -27,9 +27,6 @@ extern "C" {
* GLOBAL PROTOTYPES
**********************/
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp);
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp);
/**********************
* MACROS
**********************/

View File

@@ -20,6 +20,10 @@
* DEFINES
*********************/
#if LV_INDEV_DRAG_THROW <= 0
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
#endif
/**********************
* TYPEDEFS
**********************/
@@ -140,7 +144,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
if(indev->driver.type != LV_INDEV_TYPE_POINTER) return;
indev->cursor = cur_obj;
lv_obj_set_parent(indev->cursor, lv_layer_sys());
lv_obj_set_parent(indev->cursor, lv_layer_sys(indev->driver.disp));
lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y);
}
@@ -588,13 +592,15 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*If there is no last object then search*/
if(proc->act_obj == NULL) {
pr_obj = indev_search_obj(proc, lv_layer_top(NULL));
pr_obj = indev_search_obj(proc, lv_layer_sys(NULL));
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_layer_top(NULL));
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act(NULL));
}
/*If there is last object but it is not dragged and not protected also search*/
else if(proc->drag_in_prog == 0 &&
lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now act_obj != NULL*/
pr_obj = indev_search_obj(proc, lv_layer_top(NULL));
pr_obj = indev_search_obj(proc, lv_layer_sys(NULL));
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_layer_top(NULL));
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act(NULL));
}
/*If a dragable or a protected object was the last then keep it*/

View File

@@ -50,6 +50,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
* STATIC VARIABLES
**********************/
static bool _lv_initialized = false;
/**********************
* MACROS
**********************/
@@ -63,6 +65,12 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
*/
void lv_init(void)
{
/* Do nothing if already initialized */
if (_lv_initialized) {
LV_LOG_WARN("lv_init: already inited");
return;
}
LV_LOG_TRACE("lv_init started");
/*Initialize the lv_misc modules*/
@@ -94,7 +102,7 @@ void lv_init(void)
lv_indev_init();
#endif
_lv_initialized = true;
LV_LOG_INFO("lv_init ready");
}
@@ -405,7 +413,8 @@ void lv_obj_invalidate(const lv_obj_t * obj)
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
lv_disp_t * disp = lv_scr_get_disp(obj_scr);
if(obj_scr == lv_scr_act(disp) ||
obj_scr == lv_layer_top(disp)) {
obj_scr == lv_layer_top(disp)||
obj_scr == lv_layer_sys(disp)) {
/*Truncate recursively to the parents*/
lv_area_t area_trunc;
lv_obj_t * par = lv_obj_get_parent(obj);
@@ -1315,7 +1324,7 @@ lv_obj_t * lv_scr_act(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_last();
if(!disp) {
LV_LOG_WARN("lv_layer_top: no display registered to get its top layer");
LV_LOG_WARN("lv_scr_act: no display registered to get its top layer");
return NULL;
}
@@ -1337,6 +1346,21 @@ lv_obj_t * lv_layer_top(lv_disp_t * disp)
return disp->top_layer;
}
/**
* Return with the sys. layer. (Same on every screen and it is above the normal screen layer)
* @return pointer to the sys layer object (transparent screen sized lv_obj)
*/
lv_obj_t * lv_layer_sys(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_last();
if(!disp) {
LV_LOG_WARN("lv_layer_sys: no display registered to get its top layer");
return NULL;
}
return disp->sys_layer;
}
/**
* Return with the screen of an object
* @param obj pointer to an object

View File

@@ -571,6 +571,12 @@ lv_obj_t * lv_scr_act(lv_disp_t * disp);
*/
lv_obj_t * lv_layer_top(lv_disp_t * disp);
/**
* Return with the sys. layer. (Same on every screen and it is above the normal screen layer)
* @return pointer to the sys layer object (transparent screen sized lv_obj)
*/
lv_obj_t * lv_layer_sys(lv_disp_t * disp);
/**
* Return with the screen of an object
* @param obj pointer to an object

View File

@@ -9,10 +9,12 @@
#include <stddef.h>
#include "lv_refr.h"
#include "lv_vdb.h"
#include "lv_disp.h"
#include "../lv_hal/lv_hal_tick.h"
#include "../lv_hal/lv_hal_disp.h"
#include "../lv_misc/lv_task.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_gc.h"
/*********************
* DEFINES
@@ -53,6 +55,7 @@ static uint16_t inv_buf_p;
static void (*monitor_cb)(uint32_t, uint32_t); /*Monitor the rendering time*/
static void (*round_cb)(lv_area_t *); /*If set then called to modify invalidated areas for special display controllers*/
static uint32_t px_num;
static lv_disp_t * disp_refr; /*Display being refreshed*/
/**********************
* MACROS
@@ -172,6 +175,15 @@ void lv_refr_pop_from_buf(uint16_t num)
else inv_buf_p -= num;
}
/**
* Get the display which is being refreshed
* @return the display being refreshed
*/
lv_disp_t * lv_refr_get_disp_refreshing(void)
{
return disp_refr;
}
/**********************
* STATIC FUNCTIONS
**********************/
@@ -184,14 +196,12 @@ static void lv_refr_task(void * param)
{
(void)param;
LV_LOG_TRACE("display refresh task started");
LV_LOG_TRACE("lv_refr_task: started");
uint32_t start = lv_tick_get();
if(lv_disp_get_active() == NULL) {
LV_LOG_TRACE("No display is registered");
return;
}
LL_READ(LV_GC_ROOT(_lv_disp_ll), disp_refr) {
LV_LOG_TRACE("lv_refr_task: refreshing a display");
lv_refr_join_area();
@@ -245,8 +255,9 @@ static void lv_refr_task(void * param)
monitor_cb(lv_tick_elaps(start), px_num);
}
}
}
LV_LOG_TRACE("display refresh task finished");
LV_LOG_TRACE("lv_refr_task: ready");
}
@@ -442,14 +453,14 @@ static void lv_refr_area_part_vdb(const lv_area_t * area_p)
lv_area_intersect(&start_mask, area_p, &vdb_p->area);
/*Get the most top object which is not covered by others*/
top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act());
top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act(disp_refr));
/*Do the refreshing from the top object*/
lv_refr_obj_and_children(top_p, &start_mask);
/*Also refresh top and sys layer unconditionally*/
lv_refr_obj_and_children(lv_layer_top(), &start_mask);
lv_refr_obj_and_children(lv_layer_sys(), &start_mask);
lv_refr_obj_and_children(lv_layer_top(disp_refr), &start_mask);
lv_refr_obj_and_children(lv_layer_sys(disp_refr), &start_mask);
/* In true double buffered mode flush only once when all areas were rendered.
* In normal mode flush after every area */
@@ -507,7 +518,7 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
/* Normally always will be a top_obj (at least the screen)
* but in special cases (e.g. if the screen has alpha) it won't.
* In this case use the screen directly */
if(top_p == NULL) top_p = lv_scr_act();
if(top_p == NULL) top_p = lv_scr_act(disp_refr);
/*Refresh the top object and its children*/
lv_refr_obj(top_p, mask_p);

View File

@@ -83,6 +83,13 @@ uint16_t lv_refr_get_buf_size(void);
* @param num number of areas to delete
*/
void lv_refr_pop_from_buf(uint16_t num);
/**
* Get the display which is being refreshed
* @return the display being refreshed
*/
lv_disp_t * lv_refr_get_disp_refreshing(void);
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -11,6 +11,7 @@
#include "../lv_hal/lv_hal_disp.h"
#include "../lv_misc/lv_log.h"
#include "../lv_core/lv_refr.h"
#include <stddef.h>
/*********************
@@ -20,6 +21,10 @@
#define LV_ATTRIBUTE_FLUSH_READY
#endif
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
/**********************
* TYPEDEFS
**********************/
@@ -36,7 +41,7 @@
#if LV_VDB_DOUBLE == 0
# if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES];
static LV_ATTRIBUTE_MEM_ALIGN 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 +54,8 @@ static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
static uint8_t vdb_active = 0;
# if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
static uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES];
static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
static LV_ATTRIBUTE_MEM_ALIGN 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*/
@@ -105,7 +110,8 @@ void lv_vdb_flush(void)
vdb_flushing = true;
/*Flush the rendered content to the display*/
lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
lv_disp_t * disp = lv_refr_get_disp_refreshing();
if(disp->driver.disp_flush) disp->driver.disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
#if LV_VDB_DOUBLE

View File

@@ -11,6 +11,7 @@
#include "../lv_hal/lv_hal.h"
#include "../lv_misc/lv_font.h"
#include "../lv_core/lv_refr.h"
#include "lv_draw.h"
/*********************
@@ -84,7 +85,11 @@ void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
}
if(union_ok != false) {
lv_disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
lv_disp_t * disp = lv_refr_get_disp_refreshing();
if(disp->driver.disp_fill) {
disp->driver.disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
}
}
}
@@ -227,6 +232,9 @@ void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*If there are common part of the mask and map then draw the map*/
if(union_ok == false) return;
lv_disp_t * disp = lv_refr_get_disp_refreshing();
if(disp->driver.disp_map == NULL) return;
/*Go to the first pixel*/
lv_coord_t map_width = lv_area_get_width(cords_p);
map_p += (masked_a.y1 - cords_p->y1) * map_width * sizeof(lv_color_t);
@@ -236,7 +244,7 @@ void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
if(recolor_opa == LV_OPA_TRANSP && chroma_key == false) {
lv_coord_t mask_w = lv_area_get_width(&masked_a) - 1;
for(row = masked_a.y1; row <= masked_a.y2; row++) {
lv_disp_map(masked_a.x1, row, masked_a.x1 + mask_w, row, (lv_color_t *)map_p);
disp->driver.disp_map(masked_a.x1, row, masked_a.x1 + mask_w, row, (lv_color_t *)map_p);
map_p += map_width * sizeof(lv_color_t); /*Next row on the map*/
}
} else {

View File

@@ -9,6 +9,7 @@
#include <stdint.h>
#include <string.h>
#include "../lv_core/lv_refr.h"
#include "../lv_hal/lv_hal.h"
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_font.h"
@@ -30,6 +31,10 @@
*********************/
#define VFILL_HW_ACC_SIZE_LIMIT 50 /*Always fill < 50 px with 'sw_color_fill' because of the hw. init overhead*/
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
/**********************
* TYPEDEFS
**********************/
@@ -87,7 +92,7 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
x -= vdb_p->area.x1;
y -= vdb_p->area.y1;
lv_disp_t * disp = lv_disp_get_active();
lv_disp_t * disp = lv_refr_get_disp_refreshing();
if(disp->driver.vdb_wr) {
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa);
} else {
@@ -134,6 +139,8 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*If there are common part of the three area then draw to the vdb*/
if(union_ok == false) return;
lv_disp_t * disp = lv_refr_get_disp_refreshing();
lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/
vdb_rel_a.x1 = res_a.x1 - vdb_p->area.x1;
vdb_rel_a.y1 = res_a.y1 - vdb_p->area.y1;
@@ -147,7 +154,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
#if USE_LV_GPU
static lv_color_t color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/
static LV_ATTRIBUTE_MEM_ALIGN lv_color_t color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/
static lv_coord_t last_width = -1;
lv_coord_t w = lv_area_get_width(&vdb_rel_a);
@@ -158,16 +165,16 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*Not opaque fill*/
else if(opa == LV_OPA_COVER) {
/*Use hw fill if present*/
if(lv_disp_is_mem_fill_supported()) {
if(disp->driver.mem_fill) {
lv_coord_t row;
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
lv_disp_mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color);
disp->driver.mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color);
vdb_buf_tmp += vdb_width;
}
}
/*Use hw blend if present and the area is not too small*/
else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT &&
lv_disp_is_mem_blend_supported()) {
disp->driver.mem_blend) {
/*Fill a one line sized buffer with a color and blend this later*/
if(color_array_tmp[0].full != color.full || last_width != w) {
uint16_t i;
@@ -180,7 +187,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*Blend the filled line to every line VDB line-by-line*/
lv_coord_t row;
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
vdb_buf_tmp += vdb_width;
}
@@ -194,7 +201,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*Fill with opacity*/
else {
/*Use hw blend if present*/
if(lv_disp_is_mem_blend_supported()) {
if(disp->driver.mem_blend) {
if(color_array_tmp[0].full != color.full || last_width != w) {
uint16_t i;
for(i = 0; i < w; i++) {
@@ -205,7 +212,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
}
lv_coord_t row;
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
vdb_buf_tmp += vdb_width;
}
@@ -324,7 +331,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
/*Move on the map too*/
map_p += (row_start * width_byte_bpp) + ((col_start * bpp) >> 3);
lv_disp_t * disp = lv_disp_get_active();
lv_disp_t * disp = lv_refr_get_disp_refreshing();
uint8_t letter_px;
lv_opa_t px_opa;
@@ -435,7 +442,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_coord_t row;
lv_coord_t map_useful_w = lv_area_get_width(&masked_a);
lv_disp_t * disp = lv_disp_get_active();
lv_disp_t * disp = lv_refr_get_disp_refreshing();
/*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) {
@@ -455,10 +462,10 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
#if USE_LV_GPU
if(lv_disp_is_mem_blend_supported() == false) {
if(disp->driver.mem_blend == 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);
disp->driver.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);
@@ -529,21 +536,6 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
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
}
}
@@ -594,7 +586,7 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
lv_coord_t col;
lv_coord_t mem_width = lv_area_get_width(mem_area);
lv_disp_t * disp = lv_disp_get_active();
lv_disp_t * disp = lv_refr_get_disp_refreshing();
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++) {

View File

@@ -36,7 +36,6 @@
/**********************
* STATIC VARIABLES
**********************/
static lv_disp_t * active;
/**********************
* MACROS
@@ -91,11 +90,14 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
node->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
node->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
node->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
lv_obj_set_style(node->top_layer, &lv_style_transp);
lv_obj_set_style(node->sys_layer, &lv_style_transp);
return node;
}
void * lv_disp_get_next(lv_disp_t * disp)
lv_disp_t * lv_disp_get_next(lv_disp_t * disp)
{
if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp);
@@ -121,7 +123,7 @@ lv_disp_t * lv_disp_next(lv_disp_t * disp)
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_active();
if(disp == NULL) disp = lv_disp_get_last();
if(disp == NULL) return LV_HOR_RES_MAX;
else return disp->driver.hor_res;
@@ -130,116 +132,12 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_active();
if(disp == NULL) disp = lv_disp_get_last();
if(disp == NULL) return LV_VER_RES_MAX;
else return disp->driver.ver_res;
}
/**
* Write the content of the internal buffer (VDB) to the display
* @param x1 left coordinate of the rectangle
* @param x2 right coordinate of the rectangle
* @param y1 top coordinate of the rectangle
* @param y2 bottom coordinate of the rectangle
* @param color_p fill color
*/
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color)
{
if(active == NULL) return;
if(active->driver.disp_fill != NULL) active->driver.disp_fill(x1, y1, x2, y2, color);
}
/**
* Fill a rectangular area with a color on the active display
* @param x1 left coordinate of the rectangle
* @param x2 right coordinate of the rectangle
* @param y1 top coordinate of the rectangle
* @param y2 bottom coordinate of the rectangle
* @param color_p pointer to an array of colors
*/
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p)
{
if(active == NULL) return;
if(active->driver.disp_flush != NULL) {
LV_LOG_TRACE("disp flush started");
active->driver.disp_flush(x1, y1, x2, y2, color_p);
LV_LOG_TRACE("disp flush ready");
} else {
LV_LOG_WARN("disp flush function registered");
}
}
/**
* Put a color map to a rectangular area on the active display
* @param x1 left coordinate of the rectangle
* @param x2 right coordinate of the rectangle
* @param y1 top coordinate of the rectangle
* @param y2 bottom coordinate of the rectangle
* @param color_map pointer to an array of colors
*/
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map)
{
if(active == NULL) return;
if(active->driver.disp_map != NULL) active->driver.disp_map(x1, y1, x2, y2, color_map);
}
#if USE_LV_GPU
/**
* Blend pixels to a destination memory from a source memory
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
* @param dest a memory address. Blend 'src' here.
* @param src pointer to pixel map. Blend it to 'dest'.
* @param length number of pixels in 'src'
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
*/
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
{
if(active == NULL) return;
if(active->driver.mem_blend != NULL) active->driver.mem_blend(dest, src, length, opa);
}
/**
* Fill a memory with a color (GPUs may support it)
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
* @param dest a memory address. Copy 'src' here.
* @param src pointer to pixel map. Copy it to 'dest'.
* @param length number of pixels in 'src'
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
*/
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color)
{
if(active == NULL) return;
if(active->driver.mem_fill != NULL) active->driver.mem_fill(dest, length, color);
}
/**
* Shows if memory blending (by GPU) is supported or not
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
*/
bool lv_disp_is_mem_blend_supported(void)
{
if(active == NULL) return false;
if(active->driver.mem_blend) return true;
else return false;
}
/**
* Shows if memory fill (by GPU) is supported or not
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
*/
bool lv_disp_is_mem_fill_supported(void)
{
if(active == NULL) return false;
if(active->driver.mem_fill) return true;
else return false;
}
#endif
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -70,6 +70,7 @@ typedef struct _disp_t {
lv_ll_t scr_ll;
struct _lv_obj_t * act_scr;
struct _lv_obj_t * top_layer;
struct _lv_obj_t * sys_layer;
uint8_t orientation:2;
} lv_disp_t;
@@ -101,70 +102,12 @@ lv_disp_t * lv_disp_get_last(void);
* @param disp pointer to the current display. NULL to initialize.
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
*/
lv_disp_t * lv_disp_next(lv_disp_t * disp);
lv_disp_t * lv_disp_get_next(lv_disp_t * disp);
/**
* Fill a rectangular area with a color on the active display
* @param x1 left coordinate of the rectangle
* @param x2 right coordinate of the rectangle
* @param y1 top coordinate of the rectangle
* @param y2 bottom coordinate of the rectangle
* @param color_p pointer to an array of colors
*/
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);
/**
* Fill a rectangular area with a color on the active display
* @param x1 left coordinate of the rectangle
* @param x2 right coordinate of the rectangle
* @param y1 top coordinate of the rectangle
* @param y2 bottom coordinate of the rectangle
* @param color fill color
*/
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp);
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp);
/**
* Put a color map to a rectangular area on the active display
* @param x1 left coordinate of the rectangle
* @param x2 right coordinate of the rectangle
* @param y1 top coordinate of the rectangle
* @param y2 bottom coordinate of the rectangle
* @param color_map pointer to an array of colors
*/
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map);
#if USE_LV_GPU
/**
* Blend pixels to a destination memory from a source memory
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
* @param dest a memory address. Blend 'src' here.
* @param src pointer to pixel map. Blend it to 'dest'.
* @param length number of pixels in 'src'
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
*/
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
/**
* Fill a memory with a color (GPUs may support it)
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
* @param dest a memory address. Copy 'src' here.
* @param src pointer to pixel map. Copy it to 'dest'.
* @param length number of pixels in 'src'
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
*/
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
/**
* Shows if memory blending (by GPU) is supported or not
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
*/
bool lv_disp_is_mem_blend_supported(void);
/**
* Shows if memory fill (by GPU) is supported or not
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
*/
bool lv_disp_is_mem_fill_supported(void);
#endif
/**********************
* MACROS
**********************/

View File

@@ -11,6 +11,7 @@
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_gc.h"
#include "lv_hal_disp.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE

View File

@@ -17,9 +17,7 @@ extern "C" {
*********************/
#include <stdbool.h>
#include <stdint.h>
#include "lv_hal.h"
#include "../lv_misc/lv_area.h"
//#include "../lv_core/lv_obj.h"
/*********************
* DEFINES
@@ -29,6 +27,8 @@ extern "C" {
* TYPEDEFS
**********************/
struct _disp_t;
/*Possible input device types*/
enum {
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
@@ -62,9 +62,8 @@ typedef struct {
typedef struct {
lv_hal_indev_type_t type; /*Input device type*/
bool (*read)(lv_indev_data_t *data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/
lv_disp_t * disp;
struct _disp_t * disp;
void *user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
} lv_indev_drv_t;
struct _lv_obj_t;
@@ -114,7 +113,6 @@ typedef struct _lv_indev_t {
lv_indev_proc_t proc;
lv_indev_feedback_t feedback;
uint32_t last_activity_time;
lv_disp_t * disp;
union {
struct _lv_obj_t *cursor; /*Cursor for LV_INPUT_TYPE_POINTER*/
struct _lv_group_t *group; /*Keypad destination group*/

View File

@@ -393,14 +393,14 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
#endif
#define LV_COLOR_HEX(c) LV_COLOR_MAKE(((uint32_t)((uint32_t)c >> 16) & 0xFF), \
((uint32_t)((uint32_t)c >> 8) & 0xFF), \
((uint32_t) c & 0xFF))
#define LV_COLOR_HEX(c) LV_COLOR_MAKE((uint8_t) ((uint32_t)((uint32_t)c >> 16) & 0xFF), \
(uint8_t) ((uint32_t)((uint32_t)c >> 8) & 0xFF), \
(uint8_t) ((uint32_t) c & 0xFF))
/*Usage LV_COLOR_HEX3(0x16C) which means LV_COLOR_HEX(0x1166CC)*/
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((uint8_t) (((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
(uint8_t) ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
(uint8_t) ((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
static inline lv_color_t lv_color_hex(uint32_t c){
return LV_COLOR_HEX(c);

View File

@@ -340,9 +340,27 @@ void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coor
lv_coord_t j;
for(i = 0; i < h; i++) {
for(j = 0; j < w; j++) {
#if LV_COLOR_DEPTH == 32
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 8;
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 8;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 8;
#elif LV_COLOR_DEPTH == 16
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 5;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 5;
# if LV_COLOR_16_SWAP == 0
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 6;
# else
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 6;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 6;
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 6;
# endif /*LV_COLOR_16_SWAP*/
#elif LV_COLOR_DEPTH == 8
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 3;
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 3;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 2;
#endif
}
copy_buf_color += w;
canvas_buf_color += ext->dsc.header.w;

View File

@@ -764,12 +764,18 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
*/
static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mask)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_coord_t w = lv_obj_get_width(chart);
/*Vertical lines works only if the width == point count. Else use the normal line type*/
if(ext->point_cnt != w) {
lv_chart_draw_lines(chart, mask);
return;
}
uint16_t i;
lv_point_t p1;
lv_point_t p2;
lv_coord_t w = lv_obj_get_width(chart);
lv_coord_t h = lv_obj_get_height(chart);
lv_coord_t x_ofs = chart->coords.x1;
lv_coord_t y_ofs = chart->coords.y1;
@@ -789,11 +795,9 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
p2.x = 0 + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p1.y = LV_COORD_MIN;
p2.y = h - y_tmp + y_ofs;
p1.y = p2.y;
if(ext->point_cnt == w)
{
for(i = 0; i < ext->point_cnt; i++)
{
@@ -806,31 +810,14 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
p2.x++;
}
if(ser->points[i] != LV_CHART_POINT_DEF) {
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
}
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
p1.x = p2.x;
p1.y = p2.y;
}
}
else
{
for(i = 1; i < ext->point_cnt; i ++) {
p1.x = p2.x;
p1.y = p2.y;
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
if(ser->points[i - 1] >= 0 && ser->points[i] >= 0)
{
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
}
}
}
}
}
#endif

View File

@@ -62,10 +62,10 @@ typedef struct
/*Chart types*/
enum
{
LV_CHART_TYPE_LINE = 0x01,
LV_CHART_TYPE_COLUMN = 0x02,
LV_CHART_TYPE_POINT = 0x04,
LV_CHART_TYPE_VERTICAL_LINE = 0x08,
LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/
LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/
LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/
LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
};
typedef uint8_t lv_chart_type_t;

View File

@@ -567,7 +567,7 @@ void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
a.repeat_pause = 0;
lv_anim_create(&a);
#else
lv_obj_set_y(scrl, lv_obj_get_x(scrl) + dist);
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + dist);
#endif
}

View File

@@ -67,16 +67,15 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
ext->ta.accapted_chars = "1234567890+-.";
ext->value = 0;
ext->dec_point_pos = 2;
ext->dec_point_pos = 0;
ext->digit_count = 5;
ext->step = 100;
ext->digit_padding_left = 0;
ext->step = 1;
ext->range_max = 99999;
ext->range_min = -99999;
ext->value_changed_cb = NULL;
lv_ta_set_cursor_type(new_spinbox, LV_CURSOR_BLOCK | LV_CURSOR_HIDDEN); /*hidden by default*/
lv_ta_set_cursor_pos(new_spinbox, 4);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_spinbox, lv_spinbox_signal);
@@ -450,8 +449,8 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
int i = 0;
uint8_t digits[16];
if(v < 0)
v = -v;
if(v < 0) v = -v;
for(i = 0; i < dc; i++)
{
digits[i] = v%10;
@@ -464,6 +463,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
ext->digits[1 + pl + k] = '0' + digits[--i];
}
if(ext->dec_point_pos != 0) {
ext->digits[1 + pl + intDigits] = '.';
int d;
@@ -474,8 +474,13 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
}
ext->digits[1 + pl + intDigits + 1 + decDigits] = '\0';
} else {
ext->digits[1 + pl + intDigits] = '\0';
lv_label_set_text(ext->ta.label, (char*)ext->digits);
}
lv_ta_set_text(spinbox, (char*)ext->digits);
int32_t step = ext->step;
uint8_t cPos = ext->digit_count + pl;

View File

@@ -114,6 +114,7 @@ static void basic_init(void)
panel.body.border.width = 2;
panel.body.border.opa = LV_OPA_60;
panel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
panel.image.color = lv_color_hsv_to_rgb(_hue, 8, 96);
panel.line.color = lv_color_hsv_to_rgb(_hue, 20, 70);
/*Scrollbar*/
@@ -156,6 +157,7 @@ static void btn_init(void)
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;
btn_rel.image.color = lv_color_hsv_to_rgb(_hue, 8, 96);
lv_style_copy(&btn_pr, &btn_rel);
btn_pr.body.opa = LV_OPA_COVER;
@@ -165,6 +167,7 @@ static void btn_init(void)
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);
btn_pr.image.color = lv_color_hsv_to_rgb(_hue, 10, 100);
lv_style_copy(&btn_trel, &btn_pr);
btn_trel.body.opa = LV_OPA_COVER;
@@ -175,6 +178,7 @@ static void btn_init(void)
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);
btn_trel.image.color = lv_color_hsv_to_rgb(_hue, 0, 100);
lv_style_copy(&btn_tpr, &btn_trel);
btn_tpr.body.opa = LV_OPA_COVER;
@@ -185,6 +189,7 @@ static void btn_init(void)
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);
btn_tpr.image.color = lv_color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_ina, &btn_rel);
btn_ina.body.border.opa = LV_OPA_60;
@@ -615,6 +620,7 @@ static void list_init(void)
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;
list_rel.image.color = lv_color_hsv_to_rgb(_hue, 10, 94);
lv_style_copy(&list_pr, &list_rel);
list_pr.body.empty = 0;
@@ -622,6 +628,7 @@ static void list_init(void)
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);
list_pr.image.color = lv_color_hsv_to_rgb(_hue, 7, 96);
lv_style_copy(&list_trel, &list_rel);
lv_style_copy(&list_tpr, &list_pr);
@@ -787,6 +794,7 @@ static void win_init(void)
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);
header.image.color = lv_color_hsv_to_rgb(_hue, 5, 100);
theme.win.bg = &bg;
theme.win.sb = &sb;

View File

@@ -72,6 +72,7 @@ static void basic_init(void)
panel.body.padding.ver = LV_DPI / 8;
panel.body.padding.inner = LV_DPI / 12;
panel.text.color = LV_COLOR_HEX3(0x333);
panel.image.color = LV_COLOR_HEX3(0x333);
lv_style_copy(&sb, &def);
sb.body.main_color = LV_COLOR_BLACK;
@@ -109,6 +110,7 @@ static void btn_init(void)
rel.body.shadow.type = LV_SHADOW_BOTTOM;
rel.body.shadow.width = 6;
rel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);
rel.image.color = lv_color_hsv_to_rgb(_hue, 5, 95);
lv_style_copy(&pr, &rel);
@@ -131,6 +133,7 @@ static void btn_init(void)
ina.body.grad_color = ina.body.main_color;
ina.body.shadow.width = 0;
ina.text.color = lv_color_hsv_to_rgb(_hue, 95, 5);
ina.image.color = lv_color_hsv_to_rgb(_hue, 95, 5);
theme.btn.rel = &rel;
theme.btn.pr = &pr;
@@ -760,6 +763,7 @@ static void win_init(void)
header.body.padding.hor = 0;
header.body.padding.ver = 0;
header.text.color = LV_COLOR_HEX3(0x333);
header.image.color = LV_COLOR_HEX3(0x333);
lv_style_copy(&pr, &def);
pr.body.main_color = LV_COLOR_HEX3(0xbbb);
@@ -768,6 +772,7 @@ static void win_init(void)
pr.body.empty = 0;
pr.body.radius = 0;
pr.text.color = LV_COLOR_HEX3(0x111);
pr.image.color = LV_COLOR_HEX3(0x111);
theme.win.bg = theme.panel;

View File

@@ -59,6 +59,7 @@ static void basic_init(void)
bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 11, 30);
bg.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);
bg.text.font = _font;
bg.image.color = lv_color_hsv_to_rgb(_hue, 5, 95);
lv_style_copy(&sb, &def);
sb.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 60);
@@ -109,6 +110,7 @@ static void btn_init(void)
btn_rel.body.shadow.color = LV_COLOR_HEX3(0x111);
btn_rel.body.shadow.width = LV_DPI / 30;
btn_rel.text.color = LV_COLOR_HEX3(0xeee);
btn_rel.image.color = LV_COLOR_HEX3(0xeee);
lv_style_copy(&btn_pr, &btn_rel);
btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 30);
@@ -119,18 +121,21 @@ static void btn_init(void)
btn_tgl_rel.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 40);
btn_tgl_rel.body.shadow.width = LV_DPI / 40;
btn_tgl_rel.text.color = LV_COLOR_HEX3(0xddd);
btn_tgl_rel.image.color = LV_COLOR_HEX3(0xddd);
lv_style_copy(&btn_tgl_pr, &btn_rel);
btn_tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 10);
btn_tgl_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 30);
btn_tgl_pr.body.shadow.width = LV_DPI / 30;
btn_tgl_pr.text.color = LV_COLOR_HEX3(0xddd);
btn_tgl_pr.image.color = LV_COLOR_HEX3(0xddd);
lv_style_copy(&btn_ina, &btn_rel);
btn_ina.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 20);
btn_ina.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 20);
btn_ina.text.color = LV_COLOR_HEX3(0xaaa);
btn_ina.body.shadow.width = 0;
btn_ina.text.color = LV_COLOR_HEX3(0xaaa);
btn_ina.image.color = LV_COLOR_HEX3(0xaaa);
theme.btn.rel = &btn_rel;
theme.btn.pr = &btn_pr;
@@ -678,6 +683,7 @@ static void win_init(void)
win_btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 10);
win_btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 10);
win_btn_pr.text.color = LV_COLOR_HEX3(0xaaa);
win_btn_pr.image.color = LV_COLOR_HEX3(0xaaa);
theme.win.bg = &win_bg;
theme.win.sb = &sb;

View File

@@ -52,6 +52,7 @@ static void basic_init(void)
def.body.border.opa = LV_OPA_COVER;
def.text.font = _font;
def.text.color = LV_COLOR_HEX3(0x444);
def.image.color = LV_COLOR_HEX3(0x444);
lv_style_copy(&bg, &def);
bg.body.main_color = LV_COLOR_WHITE;
@@ -106,19 +107,23 @@ static void btn_init(void)
rel.body.padding.hor = LV_DPI / 4;
rel.body.padding.ver = LV_DPI / 8;
rel.text.color = lv_color_hsv_to_rgb(_hue, 40, 90);
rel.image.color = lv_color_hsv_to_rgb(_hue, 40, 90);
lv_style_copy(&pr, &rel);
pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 60);
pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60);
pr.body.shadow.width = 0;
pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60);
pr.image.color = lv_color_hsv_to_rgb(_hue, 40, 60);
lv_style_copy(&tgl_pr, &pr);
tgl_pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50);
tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 50);
tgl_pr.image.color = lv_color_hsv_to_rgb(_hue, 40, 50);
lv_style_copy(&ina, &tgl_pr);
ina.body.border.color = LV_COLOR_HEX3(0xbbb);
ina.text.color = LV_COLOR_HEX3(0xbbb);
ina.image.color = LV_COLOR_HEX3(0xbbb);
theme.btn.rel = &rel;
theme.btn.pr = &pr;
@@ -584,18 +589,22 @@ static void list_init(void)
rel.body.padding.hor = LV_DPI / 8;
rel.body.padding.ver = LV_DPI / 8;
rel.text.color = LV_COLOR_HEX3(0x666);
rel.image.color = LV_COLOR_HEX3(0x666);
lv_style_copy(&pr, &rel);
pr.text.color = theme.btn.pr->text.color;
pr.image.color = theme.btn.pr->image.color;
lv_style_copy(&tgl_rel, &rel);
tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
lv_style_copy(&tgl_pr, &rel);
tgl_pr.text.color = theme.btn.tgl_pr->text.color;
tgl_pr.image.color = theme.btn.tgl_pr->image.color;
lv_style_copy(&ina, &rel);
ina.text.color = theme.btn.ina->text.color;
ina.image.color = theme.btn.ina->image.color;
theme.list.sb = &sb;
theme.list.bg = &bg;
@@ -727,14 +736,17 @@ static void win_init(void)
header.body.border.part = LV_BORDER_BOTTOM;
header.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90);
header.text.color = LV_COLOR_HEX3(0x666);
header.image.color = LV_COLOR_HEX3(0x666);
lv_style_copy(&rel, &def);
rel.body.empty = 1;
rel.body.border.width = 0;
rel.text.color = LV_COLOR_HEX3(0x666);
rel.image.color = LV_COLOR_HEX3(0x666);
lv_style_copy(&pr, &rel);
pr.text.color = LV_COLOR_HEX3(0x333);
pr.image.color = LV_COLOR_HEX3(0x333);
theme.win.bg = theme.panel;
theme.win.sb = &sb;