multi_disp: add dynamic hor/ver res
This commit is contained in:
@@ -62,10 +62,10 @@
|
||||
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#ifndef LV_HOR_RES
|
||||
#define LV_HOR_RES (480)
|
||||
//#define LV_HOR_RES (480)
|
||||
#endif
|
||||
#ifndef LV_VER_RES
|
||||
#define LV_VER_RES (320)
|
||||
//#define LV_VER_RES (320)
|
||||
#endif
|
||||
|
||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||
|
||||
54
lv_core/lv_disp.c
Normal file
54
lv_core/lv_disp.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file lv_disp.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_disp.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_active();
|
||||
|
||||
if(disp == NULL) return LV_HOR_RES_MAX;
|
||||
else return disp->driver.hor_res;
|
||||
}
|
||||
|
||||
|
||||
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_active();
|
||||
|
||||
if(disp == NULL) return LV_VER_RES_MAX;
|
||||
else return disp->driver.ver_res;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
42
lv_core/lv_disp.h
Normal file
42
lv_core/lv_disp.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file lv_disp.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DISP_H
|
||||
#define LV_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* 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
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEMPL_H*/
|
||||
@@ -144,8 +144,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
/*Set coordinates to full screen size*/
|
||||
new_obj->coords.x1 = 0;
|
||||
new_obj->coords.y1 = 0;
|
||||
new_obj->coords.x2 = LV_HOR_RES - 1;
|
||||
new_obj->coords.y2 = LV_VER_RES - 1;
|
||||
new_obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1;
|
||||
new_obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Init realign*/
|
||||
|
||||
@@ -33,7 +33,7 @@ extern "C" {
|
||||
*********************/
|
||||
|
||||
/*Error check of lv_conf.h*/
|
||||
#if LV_HOR_RES == 0 || LV_VER_RES == 0
|
||||
#if LV_HOR_RES_MAX == 0 || LV_VER_RES_MAX == 0
|
||||
#error "LittlevGL: LV_HOR_RES and LV_VER_RES must be greater than 0"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@ void lv_inv_area(const lv_area_t * area_p)
|
||||
lv_area_t scr_area;
|
||||
scr_area.x1 = 0;
|
||||
scr_area.y1 = 0;
|
||||
scr_area.x2 = LV_HOR_RES - 1;
|
||||
scr_area.y2 = LV_VER_RES - 1;
|
||||
scr_area.x2 = LV_HOR_RES_MAX - 1;
|
||||
scr_area.y2 = LV_VER_RES_MAX - 1;
|
||||
|
||||
lv_area_t com_area;
|
||||
bool suc;
|
||||
@@ -346,7 +346,7 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
|
||||
/*Calculate the max row num*/
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
lv_coord_t y2 = area_p->y2 >= LV_VER_RES ? y2 = LV_VER_RES - 1 : area_p->y2;
|
||||
lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(NULL) ? y2 = lv_disp_get_ver_res(NULL) - 1 : area_p->y2;
|
||||
|
||||
int32_t max_row = (uint32_t) LV_VDB_SIZE / w;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
union_ok = lv_area_intersect(&masked_area, cords_p, mask_p);
|
||||
} else {
|
||||
lv_area_t scr_area;
|
||||
lv_area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_VER_RES - 1);
|
||||
lv_area_set(&scr_area, 0, 0, lv_disp_get_hor_res(NULL) - 1, lv_disp_get_ver_res(NULL) - 1);
|
||||
union_ok = lv_area_intersect(&masked_area, cords_p, &scr_area);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,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]; /*Used by 'lv_disp_mem_blend'*/
|
||||
static 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);
|
||||
|
||||
@@ -20,6 +20,7 @@ extern "C" {
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_core/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -97,7 +97,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_btnm, LV_HOR_RES / 2, LV_VER_RES / 4);
|
||||
lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2);
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||
|
||||
/*Set the default styles*/
|
||||
|
||||
@@ -90,7 +90,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new chart background object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3);
|
||||
lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
|
||||
@@ -102,7 +102,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new keyboard keyboard*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_kb, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_set_size(new_kb, LV_DPI * 3, LV_DPI * 2);
|
||||
lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_btnm_set_action(new_kb, lv_kb_def_action);
|
||||
lv_btnm_set_map(new_kb, kb_map_lc);
|
||||
|
||||
@@ -91,7 +91,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
|
||||
lv_cont_set_fit(new_mbox, false, true);
|
||||
lv_obj_set_width(new_mbox, LV_HOR_RES / 2);
|
||||
lv_obj_set_width(new_mbox, LV_DPI * 2);
|
||||
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Set the default styles*/
|
||||
|
||||
@@ -106,7 +106,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->tab_name_ptr[0] = "";
|
||||
ext->tab_cnt = 0;
|
||||
|
||||
lv_obj_set_size(new_tabview, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_size(new_tabview, LV_DPI * 3, LV_DPI * 2);
|
||||
|
||||
ext->btns = lv_btnm_create(new_tabview, NULL);
|
||||
lv_obj_set_height(ext->btns, 3 * LV_DPI / 4);
|
||||
@@ -123,7 +123,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_cont_set_fit(ext->content, true, false);
|
||||
lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
|
||||
lv_cont_set_style(ext->content, &lv_style_transp_tight);
|
||||
lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns));
|
||||
lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns));
|
||||
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
/*Set the default styles*/
|
||||
|
||||
@@ -89,7 +89,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new tileview*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_tileview, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_size(new_tileview, LV_DPI * 3, LV_DPI * 3);
|
||||
lv_obj_set_drag_throw(lv_page_get_scrl(new_tileview), false);
|
||||
lv_page_set_scrl_fit(new_tileview, true, true);
|
||||
/*Set the default styles*/
|
||||
@@ -506,8 +506,8 @@ static void drag_end_handler(lv_obj_t * tileview)
|
||||
lv_obj_t * scrl = lv_page_get_scrl(tileview);
|
||||
lv_point_t p;
|
||||
|
||||
p.x = - (scrl->coords.x1 - LV_HOR_RES / 2);
|
||||
p.y = - (scrl->coords.y1 - LV_VER_RES / 2);
|
||||
p.x = - (scrl->coords.x1 - lv_obj_get_width(tileview) / 2);
|
||||
p.y = - (scrl->coords.y1 - lv_obj_get_height(tileview) / 2);
|
||||
|
||||
/*From the drag vector (drag throw) predict the end position*/
|
||||
if(ext->drag_hor) {
|
||||
|
||||
@@ -70,7 +70,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new window object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_size(new_win, LV_DPI * 3, LV_DPI * 3);
|
||||
lv_obj_set_pos(new_win, 0, 0);
|
||||
lv_obj_set_style(new_win, &lv_style_pretty);
|
||||
|
||||
@@ -107,7 +107,6 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user