mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge branch 'master' into font_icon
This commit is contained in:
commit
f47f999480
@ -1021,9 +1021,9 @@ static void lv_app_init_style(void)
|
||||
app_style.sc_page_style.bg_rects.hpad = 0;
|
||||
app_style.sc_page_style.bg_rects.opad = 0;
|
||||
app_style.sc_page_style.scrl_rects.objs.transp = 1;
|
||||
app_style.sc_page_style.scrl_rects.hpad = 20 * LV_DOWNSCALE;
|
||||
app_style.sc_page_style.scrl_rects.vpad = 20 * LV_DOWNSCALE;
|
||||
app_style.sc_page_style.scrl_rects.opad = 20 * LV_DOWNSCALE;
|
||||
app_style.sc_page_style.scrl_rects.hpad = 10 * LV_DOWNSCALE;
|
||||
app_style.sc_page_style.scrl_rects.vpad = 10 * LV_DOWNSCALE;
|
||||
app_style.sc_page_style.scrl_rects.opad = 15 * LV_DOWNSCALE;
|
||||
|
||||
/*Shortcut styles*/
|
||||
lv_btns_get(LV_BTNS_DEF,&app_style.sc_style);
|
||||
|
120
lv_app/lv_app.h
120
lv_app/lv_app.h
@ -9,6 +9,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0
|
||||
@ -82,7 +83,6 @@ typedef struct {
|
||||
lv_labels_t sc_title_style;
|
||||
lv_labels_t sc_txt_style;
|
||||
|
||||
|
||||
opa_t menu_opa;
|
||||
opa_t menu_btn_opa;
|
||||
opa_t sc_opa;
|
||||
@ -101,28 +101,130 @@ typedef struct {
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application system
|
||||
*/
|
||||
void lv_app_init(void);
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to an application specific configuration structure or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
lv_app_inst_t * lv_app_run(const lv_app_dsc_t * app_dsc, void * conf);
|
||||
|
||||
/**
|
||||
* Close a running application. Close the Window and the Shortcut too if opened.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_close(lv_app_inst_t * app);
|
||||
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @return pointer to the shortcut
|
||||
*/
|
||||
lv_obj_t * lv_app_sc_open(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_sc_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @return pointer to the shortcut
|
||||
*/
|
||||
lv_obj_t * lv_app_win_open(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_win_close(lv_app_inst_t * app);
|
||||
lv_obj_t * lv_app_win_get_from_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Send data to other applications
|
||||
* @param app_send pointer to the application which is sending the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
* @return number application which were received the message
|
||||
*/
|
||||
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
|
||||
/**
|
||||
* Test an application communication connection
|
||||
* @param sender pointer to an application which sends data
|
||||
* @param receiver pointer to an application which receives data
|
||||
* @return false: no connection, true: there is connection
|
||||
*/
|
||||
bool lv_app_con_check(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Create a new connection between two applications
|
||||
* @param sender pointer to a data sender application
|
||||
* @param receiver pointer to a data receiver application
|
||||
*/
|
||||
void lv_app_con_set(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Delete a communication connection
|
||||
* @param sender pointer to a data sender application or NULL to be true for all sender
|
||||
* @param receiver pointer to a data receiver application or NULL to be true for all receiver
|
||||
*/
|
||||
void lv_app_con_del(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Get the application descriptor from its name
|
||||
* @param name name of the app. dsc.
|
||||
* @return pointer to the app. dsc.
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_dsc_get(const char * name);
|
||||
|
||||
bool lv_app_con_check(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
void lv_app_con_set(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
void lv_app_con_del(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
lv_app_style_t * lv_app_style_get(void);
|
||||
/**
|
||||
* Rename an application
|
||||
* @param app pointer to an application
|
||||
* @param name a string with the new name
|
||||
*/
|
||||
void lv_app_rename(lv_app_inst_t * app, const char * name);
|
||||
void lv_app_style_refr(void);
|
||||
|
||||
/**
|
||||
* Get the window object from an object located on the window
|
||||
* @param obj pointer to an object on the window
|
||||
* @return pointer to the window of 'obj'
|
||||
*/
|
||||
lv_obj_t * lv_app_win_get_from_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Read the list of the running applications. (Get he next element)
|
||||
* @param prev the previous application (at the first call give NULL to get the first application)
|
||||
* @param dsc pointer to an application descriptor to filer the applications (NULL to do not filter)
|
||||
* @return pointer to the next running application or NULL if no more
|
||||
*/
|
||||
lv_app_inst_t * lv_app_get_next(lv_app_inst_t * prev, lv_app_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Read the list of applications descriptors. (Get he next element)
|
||||
* @param prev the previous application descriptors(at the first call give NULL to get the first)
|
||||
* @return pointer to the next application descriptors or NULL if no more
|
||||
*/
|
||||
lv_app_dsc_t ** lv_app_dsc_get_next(lv_app_dsc_t ** prev);
|
||||
|
||||
const lv_app_dsc_t * lv_app_example_init(void);
|
||||
/**
|
||||
* Refresh the style of the applications
|
||||
* */
|
||||
void lv_app_style_refr(void);
|
||||
|
||||
/**
|
||||
* Get a pointer to the application style structure. If modified then 'lv_app_refr_style' should be called
|
||||
* @return pointer to the application style structure
|
||||
*/
|
||||
lv_app_style_t * lv_app_style_get(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -23,9 +23,27 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File selector utility
|
||||
*/
|
||||
void lv_app_fsel_init(void);
|
||||
void lv_app_fsel_open(const char * path, const char * filter, void * param, void (*ok_action)(void *, const char *));
|
||||
void lv_app_fsel_close();
|
||||
|
||||
/**
|
||||
* Open the File selector
|
||||
* @param path start path
|
||||
* @param filter show only files with a specific extension, e.g. "wav".
|
||||
* "/" means filter to folders.
|
||||
* @param param a free parameter which will be added to 'ok_action'
|
||||
* @param ok_action an action to call when a file or folder is chosen
|
||||
*/
|
||||
void lv_app_fsel_open(const char * path, const char * filter, void * param,
|
||||
void (*ok_action)(void *, const char *));
|
||||
|
||||
/**
|
||||
* Close the File selector
|
||||
*/
|
||||
void lv_app_fsel_close(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -73,6 +73,9 @@ static lv_btnms_t kb_btnms;
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application keyboard
|
||||
*/
|
||||
void lv_app_kb_init(void)
|
||||
{
|
||||
lv_btnms_get(LV_BTNMS_DEF, &kb_btnms);
|
||||
@ -84,7 +87,7 @@ void lv_app_kb_init(void)
|
||||
kb_btnms.rects.round = 0;
|
||||
kb_btnms.rects.bwidth = 0;
|
||||
|
||||
// kb_btnms.btns.rects.bwidth = 0;
|
||||
kb_btnms.btns.rects.bwidth = 0;
|
||||
kb_btnms.btns.rects.round = 0;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,25 @@ typedef enum
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application keyboard
|
||||
*/
|
||||
void lv_app_kb_init(void);
|
||||
|
||||
/**
|
||||
* Open a keyboard for a text area object
|
||||
* @param ta pointer to a text area object
|
||||
* @param mode 'OR'd values of 'lv_app_kb_mode_t' enum
|
||||
* @param close a function to call when the keyboard is closed
|
||||
* @param ok a function to called when the "Ok" button is pressed
|
||||
*/
|
||||
void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *));
|
||||
|
||||
/**
|
||||
* Close the keyboard
|
||||
* @param ok true: call the ok function, false: call the close function
|
||||
*/
|
||||
void lv_app_kb_close(bool ok);
|
||||
|
||||
/**********************
|
||||
|
@ -26,16 +26,12 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_action_res_t notice_rel_action(lv_obj_t * n, lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_obj_t * notice_h;
|
||||
|
||||
static lv_btns_t notice_btns;
|
||||
static lv_labels_t notice_labels;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -50,22 +46,6 @@ void lv_app_notice_init(void)
|
||||
{
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
|
||||
memcpy(¬ice_btns, &app_style->menu_style, sizeof(lv_rects_t));
|
||||
notice_btns.rects.round = 5 * LV_DOWNSCALE;
|
||||
notice_btns.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE;
|
||||
notice_btns.mcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
notice_btns.gcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
notice_btns.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE;
|
||||
notice_btns.mcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
notice_btns.gcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
notice_btns.rects.bwidth = 1 * LV_DOWNSCALE;
|
||||
notice_btns.rects.bopa = 90;
|
||||
notice_btns.rects.light = 5 * LV_DOWNSCALE;
|
||||
|
||||
memcpy(¬ice_labels, &app_style->menu_btn_label_style, sizeof(lv_labels_t));
|
||||
notice_labels.mid = 0;
|
||||
notice_labels.font = LV_APP_FONT_MEDIUM;
|
||||
|
||||
notice_h = lv_rect_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - app_style->menu_h);
|
||||
lv_obj_set_y(notice_h, app_style->menu_h);
|
||||
@ -77,8 +57,9 @@ void lv_app_notice_init(void)
|
||||
/**
|
||||
* Add a notification with a given text
|
||||
* @param format pritntf-like format string
|
||||
* @return pointer the notice which is a message box (lv_mbox) object
|
||||
*/
|
||||
void lv_app_notice_add(const char * format, ...)
|
||||
lv_obj_t * lv_app_notice_add(const char * format, ...)
|
||||
{
|
||||
char txt[LV_APP_NOTICE_MAX_LEN];
|
||||
|
||||
@ -89,77 +70,24 @@ void lv_app_notice_add(const char * format, ...)
|
||||
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
|
||||
lv_obj_t * n;
|
||||
n = lv_btn_create(notice_h, NULL);
|
||||
lv_rect_set_fit(n, true, true);
|
||||
lv_obj_set_style(n, ¬ice_btns);
|
||||
lv_obj_set_opa(n, app_style->menu_opa);
|
||||
lv_btn_set_rel_action(n, notice_rel_action);
|
||||
|
||||
lv_obj_t * l;
|
||||
l = lv_label_create(n, NULL);
|
||||
lv_label_set_text(l, txt);
|
||||
lv_obj_set_style(l, ¬ice_labels);
|
||||
lv_obj_t * mbox;
|
||||
mbox = lv_mbox_create(notice_h, NULL);
|
||||
lv_obj_set_style(mbox, lv_mboxs_get(LV_MBOXS_INFO, NULL));
|
||||
lv_mbox_set_title(mbox, "");
|
||||
lv_mbox_set_text(mbox, txt);
|
||||
lv_obj_set_opa(mbox, app_style->menu_opa);
|
||||
|
||||
#if LV_APP_NOTICE_SHOW_TIME != 0
|
||||
lv_mbox_start_auto_close(mbox, LV_APP_NOTICE_SHOW_TIME);
|
||||
#endif
|
||||
|
||||
lv_obj_set_parent(notice_h, lv_scr_act());
|
||||
|
||||
lv_rect_set_fit(n, false, false);
|
||||
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_NOTICE != 0
|
||||
anim_t a;
|
||||
a.var = n;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.time = LV_APP_ANIM_NOTICE;
|
||||
a.act_time = - LV_APP_NOTICE_SHOW_TIME;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.end_cb = NULL;
|
||||
#if LV_APP_EFFECT_OPA_ANIM != 0
|
||||
a.fp = (anim_fp_t) lv_obj_set_opar;
|
||||
a.start = lv_obj_get_opa(n);
|
||||
a.end = OPA_TRANSP;
|
||||
anim_create(&a);
|
||||
|
||||
/*Restore the label opacity because the opar anim changes it*/
|
||||
lv_obj_set_opa(l, OPA_COVER);
|
||||
|
||||
a.act_time = - LV_APP_NOTICE_SHOW_TIME - LV_APP_ANIM_NOTICE; /*Do the next animation after the opa animation*/
|
||||
#endif
|
||||
|
||||
a.fp = (anim_fp_t) lv_obj_set_height;
|
||||
a.start = lv_obj_get_height(n);
|
||||
a.end = 0;
|
||||
a.end_cb = (anim_cb_t)lv_obj_del;
|
||||
anim_create(&a);
|
||||
#else
|
||||
anim_t a;
|
||||
a.var = n;
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
a.time = LV_APP_ANIM_NOTICE;
|
||||
a.act_time = - LV_APP_NOTICE_SHOW_TIME + LV_APP_ANIM_NOTICE;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.fp = (anim_fp_t) lv_obj_set_height;
|
||||
a.start = lv_obj_get_height(n);
|
||||
a.end = lv_obj_get_height(n);
|
||||
a.end_cb = lv_obj_del;
|
||||
anim_create(&a);
|
||||
#endif
|
||||
return mbox;
|
||||
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static lv_action_res_t notice_rel_action(lv_obj_t * n, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_del(n);
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -24,8 +24,18 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Notifications
|
||||
*/
|
||||
void lv_app_notice_init(void);
|
||||
void lv_app_notice_add(const char * format, ...);
|
||||
|
||||
/**
|
||||
* Add a notification with a given text
|
||||
* @param format pritntf-like format string
|
||||
* @return pointer the notice which is a message box (lv_mbox) object
|
||||
*/
|
||||
lv_obj_t * lv_app_notice_add(const char * format, ...);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -311,7 +311,8 @@ static void sysmon_task(void * param)
|
||||
static bool mem_warn_report = false;
|
||||
if(mem_mon.size_free < LV_APP_SYSMON_MEM_WARN && mem_warn_report == false) {
|
||||
mem_warn_report = true;
|
||||
lv_app_notice_add("Critically low memory");
|
||||
lv_obj_t * not = lv_app_notice_add("Critically low memory");
|
||||
lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
|
||||
}
|
||||
|
||||
if(mem_mon.size_free > LV_APP_SYSMON_MEM_WARN) mem_warn_report = false;
|
||||
@ -320,7 +321,9 @@ static void sysmon_task(void * param)
|
||||
if(mem_mon.pct_frag > LV_APP_SYSMON_FRAG_WARN) {
|
||||
if(frag_warn_report == false) {
|
||||
frag_warn_report = true;
|
||||
lv_app_notice_add("Critically memory fragmentation");
|
||||
lv_obj_t * not =lv_app_notice_add("Critical memory\nfragmentation");
|
||||
lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
|
||||
|
||||
dm_defrag(); /*Defrag. if the fragmentation is critical*/
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,8 @@
|
||||
#define USE_FONT_DEJAVU_40 1
|
||||
#define USE_FONT_DEJAVU_60 1
|
||||
#define USE_FONT_DEJAVU_80 1
|
||||
#define USE_FONT_SYMBOL_30 1
|
||||
#define USE_FONT_SYMBOL_60 1
|
||||
#define LV_FONT_DEFAULT FONT_DEJAVU_30 /*Always set a default font*/
|
||||
#define LV_TXT_BREAK_CHARS " ,.;-" /*Can break texts on these chars*/
|
||||
|
||||
@ -93,10 +95,17 @@
|
||||
/*Line (dependencies: -*/
|
||||
#define USE_LV_LINE 1
|
||||
|
||||
/*Image (dependencies: from misc: FSINT, UFS)*/
|
||||
/*Image (dependencies: lv_label (if symbols are enabled) from misc: FSINT, UFS)*/
|
||||
#define USE_LV_IMG 1
|
||||
#if USE_LV_IMG != 0
|
||||
//#define LV_IMG_DEF_WALLPAPER img_wallpaper_var /*Comment this line to NOT use wallpaper*/
|
||||
#define LV_IMG_DEF_WALLPAPER img_square_x2 /*Comment this line to NOT use wallpaper*/
|
||||
/* 1: enables to interpret the file names as symbol name
|
||||
* from symbol_def.h if they begin with a lower case letter.
|
||||
* (driver letters are always upper case)*/
|
||||
#define LV_IMG_ENABLE_SYMBOLS 1
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#define LV_IMG_DEF_SYMBOL_FONT FONT_SYMBOL_30
|
||||
#endif /*LV_IMG_ENABLE_SYMBOLS*/
|
||||
#endif /*USE_LV_IMG*/
|
||||
|
||||
/*Page (dependencies: lv_rect)*/
|
||||
@ -135,6 +144,12 @@
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btn, lv_label)*/
|
||||
#define USE_LV_MBOX 1
|
||||
#if USE_LV_MBOX != 0
|
||||
#define LV_MBOX_ANIM_TIME 250 /*How fast animate out the message box in auto close. 0: no animation [ms]*/
|
||||
#endif
|
||||
|
||||
/*Gauge (dependencies: lv_rect, lv_label, lv_line, misc: trigo)*/
|
||||
#define USE_LV_GAUGE 1
|
||||
|
||||
/*==================
|
||||
* LV APP SETTINGS
|
||||
@ -175,7 +190,7 @@
|
||||
#define LV_APP_EFFECT_OPA_ANIM 1 /*Enable the using opacity in the application animations*/
|
||||
#define LV_APP_ANIM_WIN 200 /*Animation time in milliseconds (0: turn off animation)*/
|
||||
#define LV_APP_ANIM_SC 200 /*Animation time in milliseconds (0: turn off animation)*/
|
||||
#define LV_APP_ANIM_NOTICE 300 /*How fast animate out a notice [ms]*/
|
||||
#define LV_APP_ANIM_NOTICE 300 /*Obsolete, use LV_MBOX_ANIM. */
|
||||
|
||||
/* App. utility settings */
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000 /*Notices will be shown for this time [ms]*/
|
||||
|
@ -45,11 +45,11 @@ static uint16_t lv_draw_rect_radius_corr(uint16_t r, cord_t w, cord_t h);
|
||||
#if LV_VDB_SIZE != 0
|
||||
static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_vfill;
|
||||
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint8_t letter, color_t color, opa_t opa) = lv_vletter;
|
||||
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, color_t recolor, opa_t recolor_opa) = lv_vmap;
|
||||
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, bool upscale, color_t recolor, opa_t recolor_opa) = lv_vmap;
|
||||
#else
|
||||
static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_rfill;
|
||||
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint8_t letter, color_t color, opa_t opa) = lv_rletter;
|
||||
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, color_t recolor, opa_t recolor_opa) = lv_rmap;
|
||||
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, bool upscale, color_t recolor, opa_t recolor_opa) = lv_rmap;
|
||||
#endif
|
||||
|
||||
|
||||
@ -177,61 +177,86 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_imgs_t * imgs_p, opa_t opa, const char * fn)
|
||||
{
|
||||
if(fn == NULL) {
|
||||
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
|
||||
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, "No data");
|
||||
} else {
|
||||
fs_file_t file;
|
||||
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
cord_t row;
|
||||
color_t buf[LV_HOR_RES];
|
||||
uint32_t br;
|
||||
area_t act_area;
|
||||
if(fn == NULL) {
|
||||
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
|
||||
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, "No data");
|
||||
} else {
|
||||
fs_file_t file;
|
||||
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t br;
|
||||
res = fs_read(&file, &header, sizeof(lv_img_raw_header_t), &br);
|
||||
|
||||
area_t mask_sub;
|
||||
bool union_ok;
|
||||
union_ok = area_union(&mask_sub, mask_p, cords_p);
|
||||
if(union_ok == false) {
|
||||
fs_close(&file);
|
||||
return;
|
||||
}
|
||||
lv_img_raw_header_t header;
|
||||
res = fs_read(&file, &header, sizeof(lv_img_raw_header_t), &br);
|
||||
/*If the width is greater then map width then it is upscaled */
|
||||
bool upscale = false;
|
||||
if(area_get_width(cords_p) > header.w) upscale = true;
|
||||
|
||||
uint32_t start_offset = sizeof(lv_img_raw_header_t);
|
||||
start_offset += area_get_width(cords_p) *
|
||||
(mask_sub.y1 - cords_p->y1) * sizeof(color_t); /*First row*/
|
||||
start_offset += (mask_sub.x1 - cords_p->x1) * sizeof(color_t); /*First col*/
|
||||
fs_seek(&file, start_offset);
|
||||
cord_t row;
|
||||
area_t act_area;
|
||||
|
||||
uint32_t useful_data = area_get_width(&mask_sub) * sizeof(color_t);
|
||||
uint32_t next_row = area_get_width(cords_p) * sizeof(color_t) - useful_data;
|
||||
|
||||
area_cpy(&act_area, &mask_sub);
|
||||
area_t mask_sub;
|
||||
bool union_ok;
|
||||
union_ok = area_union(&mask_sub, mask_p, cords_p);
|
||||
if(union_ok == false) {
|
||||
fs_close(&file);
|
||||
return;
|
||||
}
|
||||
|
||||
act_area.y2 = act_area.y1;
|
||||
uint32_t act_pos;
|
||||
uint8_t ds_shift = 0;
|
||||
uint8_t ds_num = 1;
|
||||
/*Set some values if upscale enabled*/
|
||||
if(upscale != false) {
|
||||
ds_shift = 1;
|
||||
ds_num = 2;
|
||||
}
|
||||
|
||||
for(row = mask_sub.y1; row <= mask_sub.y2; row ++) {
|
||||
res = fs_read(&file, buf, useful_data, &br);
|
||||
map_fp(&act_area, &mask_sub, buf, opa, header.transp,
|
||||
imgs_p->objs.color, imgs_p->recolor_opa);
|
||||
fs_tell(&file, &act_pos);
|
||||
fs_seek(&file, act_pos + next_row);
|
||||
act_area.y1 ++;
|
||||
act_area.y2 ++;
|
||||
}
|
||||
}
|
||||
fs_close(&file);
|
||||
uint32_t start_offset = sizeof(lv_img_raw_header_t);
|
||||
start_offset += (area_get_width(cords_p) >> ds_shift) *
|
||||
((mask_sub.y1 - cords_p->y1) >> ds_shift) * sizeof(color_t); /*First row*/
|
||||
start_offset += ((mask_sub.x1 - cords_p->x1) >> ds_shift) * sizeof(color_t); /*First col*/
|
||||
fs_seek(&file, start_offset);
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
|
||||
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, fn);
|
||||
}
|
||||
}
|
||||
uint32_t useful_data = (area_get_width(&mask_sub) >> ds_shift) * sizeof(color_t);
|
||||
uint32_t next_row = (area_get_width(cords_p) >> ds_shift) * sizeof(color_t) - useful_data;
|
||||
|
||||
|
||||
/*Round the coordinates with upscale*/
|
||||
if(upscale != false) {
|
||||
if((mask_sub.x1 & 0x1) != 0) mask_sub.x1 -= 1; /*Can be only even*/
|
||||
if((mask_sub.x2 & 0x1) == 0) mask_sub.x2 -= 1; /*Can be only odd*/
|
||||
}
|
||||
area_cpy(&act_area, &mask_sub);
|
||||
|
||||
/* Round down the start coordinate, because the upscaled images
|
||||
* can start only LV_DOWNSCALE 'y' coordinates */
|
||||
act_area.y1 &= ~(cord_t)(ds_num - 1) ;
|
||||
act_area.y2 = act_area.y1 + ds_num - 1;
|
||||
uint32_t act_pos;
|
||||
|
||||
color_t buf[LV_HOR_RES];
|
||||
for(row = mask_sub.y1; row <= mask_sub.y2; row += ds_num) {
|
||||
res = fs_read(&file, buf, useful_data, &br);
|
||||
map_fp(&act_area, &mask_sub, buf, opa, header.transp, upscale,
|
||||
imgs_p->objs.color, imgs_p->recolor_opa);
|
||||
fs_tell(&file, &act_pos);
|
||||
fs_seek(&file, act_pos + next_row);
|
||||
act_area.y1 += ds_num;
|
||||
act_area.y2 += ds_num;
|
||||
}
|
||||
|
||||
}
|
||||
fs_close(&file);
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
|
||||
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /*USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0*/
|
||||
|
||||
#if USE_LV_LINE != 0
|
||||
@ -297,10 +322,10 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
last_y = act_point.y;
|
||||
last_x = act_point.x;
|
||||
|
||||
draw_area.x1 = min(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = max(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = min(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = max(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, lines_p->objs.color, opa);
|
||||
}
|
||||
if (hor == false && last_x != act_point.x) {
|
||||
@ -313,10 +338,10 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
last_y = act_point.y;
|
||||
last_x = act_point.x;
|
||||
|
||||
draw_area.x1 = min(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = max(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = min(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = max(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, lines_p->objs.color, opa);
|
||||
}
|
||||
|
||||
@ -341,10 +366,10 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
act_area.y1 = last_y - width_half ;
|
||||
act_area.y2 = act_point.y + width_half + width_1;
|
||||
|
||||
draw_area.x1 = min(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = max(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = min(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = max(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, lines_p->objs.color, opa);
|
||||
}
|
||||
if (hor == false) {
|
||||
@ -355,10 +380,10 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
act_area.y1 = last_y;
|
||||
act_area.y2 = act_point.y;
|
||||
|
||||
draw_area.x1 = min(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = max(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = min(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = max(act_area.y1, act_area.y2);
|
||||
draw_area.x1 = MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, lines_p->objs.color, opa);
|
||||
}
|
||||
}
|
||||
|
@ -28,25 +28,57 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Draw a rectangle
|
||||
* @param cords_p the coordinates of the rectangle
|
||||
* @param mask_p the rectangle will be drawn only in this mask
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa the opacity of the rectangle (0..255)
|
||||
*/
|
||||
#if USE_LV_RECT != 0
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_rects_t * rects_p, opa_t opa);
|
||||
const lv_rects_t * rects_p, opa_t opa);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Write a text
|
||||
* @param cords_p coordinates of the label
|
||||
* @param mask_p the label will be drawn only in this area
|
||||
* @param labels_p pointer to a label style
|
||||
* @param opa opacity of the text (0..255)
|
||||
* @param txt 0 terminated text to write
|
||||
*/
|
||||
#if USE_LV_LABEL != 0
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
|
||||
const lv_labels_t * labels_p, opa_t opa, const char * txt);
|
||||
#endif
|
||||
|
||||
#if USE_LV_LINE != 0
|
||||
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
const lv_lines_t * lines_p, opa_t opa);
|
||||
const lv_labels_t * labels_p, opa_t opa, const char * txt);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Draw an image
|
||||
* @param cords_p the coordinates of the image
|
||||
* @param mask_p the image will be drawn only in this area
|
||||
* @param map_p pointer to a color_t array which contains the pixels of the image
|
||||
* @param opa opacity of the image (0..255)
|
||||
*/
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_imgs_t * imgs_p, opa_t opa, const char * fn);
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_imgs_t * imgs_p, opa_t opa, const char * fn);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
* @param p1 first point of the line
|
||||
* @param p2 second point of the line
|
||||
* @param mask_pthe line will be drawn only on this area
|
||||
* @param lines_p pointer to a line style
|
||||
* @param opa opacity of the line (0..255)
|
||||
*/
|
||||
#if USE_LV_LINE != 0
|
||||
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
const lv_lines_t * lines_p, opa_t opa);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -108,9 +108,12 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size (not supported)
|
||||
* @param recolor mix the pixels with this color (not supported)
|
||||
* @param recolor_opa the intense of recoloring (not supported)
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
|
@ -24,13 +24,42 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_rfill(const area_t * area_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
/**
|
||||
* Fill an area on the display
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter to the display
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size (not supported)
|
||||
* @param recolor mix the pixels with this color (not supported)
|
||||
* @param recolor_opa the intense of recoloring (not supported)
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -175,30 +175,36 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
|
||||
/*Get the union of map size and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
* in 'lv_refr_area_with_vdb' function */
|
||||
* in 'lv_refr_area_with_vdb' function */
|
||||
union_ok = area_union(&masked_a, cords_p, mask_p);
|
||||
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
if(union_ok == false) return;
|
||||
|
||||
uint8_t ds_shift = 0;
|
||||
if(upscale != false) ds_shift = 1;
|
||||
|
||||
/*If the map starts OUT of the masked area then calc. the first pixel*/
|
||||
cord_t map_width = area_get_width(cords_p);
|
||||
cord_t map_width = area_get_width(cords_p) >> ds_shift;
|
||||
if(cords_p->y1 < masked_a.y1) {
|
||||
map_p += (uint32_t) map_width * (masked_a.y1 - cords_p->y1);
|
||||
map_p += (uint32_t) map_width * ((masked_a.y1 - cords_p->y1) >> ds_shift);
|
||||
}
|
||||
if(cords_p->x1 < masked_a.x1) {
|
||||
map_p += (masked_a.x1 - cords_p->x1);
|
||||
map_p += (masked_a.x1 - cords_p->x1) >> ds_shift;
|
||||
}
|
||||
|
||||
/*Stores coordinates relative to the act vdb*/
|
||||
@ -208,101 +214,126 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
masked_a.y2 = masked_a.y2 - vdb_p->vdb_area.y1;
|
||||
|
||||
cord_t vdb_width = area_get_width(&vdb_p->vdb_area);
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
vdb_buf_tmp += (uint32_t) vdb_width * masked_a.y1; /*Move to the first row*/
|
||||
|
||||
map_p -= masked_a.x1;
|
||||
map_p -= (masked_a.x1 >> ds_shift);
|
||||
|
||||
/*No transparent pixels on the image*/
|
||||
if(transp == false) { /*Simply copy the pixels to the VDB*/
|
||||
cord_t row;
|
||||
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
memcpy(&vdb_buf_tmp[masked_a.x1],
|
||||
&map_p[masked_a.x1],
|
||||
area_get_width(&masked_a) * sizeof(color_t));
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
cord_t col;
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
}
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
|
||||
/*To recolor draw simply a rectangle above the image*/
|
||||
#if LV_VDB_SIZE != 0
|
||||
lv_vfill(cords_p, mask_p, recolor, recolor_opa);
|
||||
#endif
|
||||
|
||||
} else { /*transp == true: Check all pixels */
|
||||
if(upscale != false) {
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
color_t color_tmp;
|
||||
color_t prev_color = COLOR_BLACK;
|
||||
cord_t map_col;
|
||||
|
||||
if(recolor_opa == OPA_TRANSP)/*No recolor*/
|
||||
{
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = map_p[col];
|
||||
}
|
||||
}
|
||||
color_tmp = color_mix(recolor, prev_color, recolor_opa);
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
map_col = col >> 1;
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else { /*Image opacity ut no recolor*/
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
if(map_p[map_col].full != prev_color.full) {
|
||||
prev_color.full = map_p[map_col].full;
|
||||
color_tmp = color_mix(recolor, prev_color, recolor_opa);
|
||||
}
|
||||
if(transp == false || map_p[map_col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = color_mix( color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
if((row & 0x1) != 0) map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width ; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(transp == false) { /*Simply copy the pixels to the VDB*/
|
||||
cord_t row;
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
} else { /*Recolor needed*/
|
||||
color_t color_tmp;
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_tmp;
|
||||
}
|
||||
}
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
memcpy(&vdb_buf_tmp[masked_a.x1],
|
||||
&map_p[masked_a.x1],
|
||||
area_get_width(&masked_a) * sizeof(color_t));
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
cord_t col;
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
}
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else { /*Image opacity with recolor*/
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_mix(color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
/*To recolor draw simply a rectangle above the image*/
|
||||
#if LV_VDB_SIZE != 0
|
||||
lv_vfill(cords_p, mask_p, recolor, recolor_opa);
|
||||
#endif
|
||||
} else { /*transp == true: Check all pixels */
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
if(recolor_opa == OPA_TRANSP) {/*No recolor*/
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = map_p[col];
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
} else { /*Recolor needed*/
|
||||
color_t color_tmp;
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_tmp;
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_mix(color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -28,16 +28,45 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter in the Virtual Display Buffer
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
|
||||
|
||||
/**********************
|
||||
|
@ -51,12 +51,43 @@ typedef struct
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the animation module
|
||||
*/
|
||||
void anim_init(void);
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param anim_p an initialized 'anim_t' variable. Not required after call.
|
||||
*/
|
||||
void anim_create(anim_t * anim_p);
|
||||
anim_path_t * anim_get_path(anim_path_name_t type);
|
||||
|
||||
/**
|
||||
* Delete an animation for a variable with a given animatior function
|
||||
* @param var pointer to variable
|
||||
* @param fp a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all animation with 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool anim_del(void * var, anim_fp_t fp);
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint16_t anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
|
||||
|
||||
/**
|
||||
* Get a predefine animation path
|
||||
* @param name name of the path from 'anim_path_name_t'
|
||||
* @return pointer to the path array
|
||||
*/
|
||||
anim_path_t * anim_get_path(anim_path_name_t name);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -49,16 +49,32 @@ void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2)
|
||||
area_p->y2 = y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void area_set_width(area_t * area_p, cord_t w)
|
||||
{
|
||||
area_p->x2 = area_p->x1 + w - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void area_set_height(area_t * area_p, cord_t h)
|
||||
{
|
||||
area_p->y2 = area_p->y1 + h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void area_set_pos(area_t * area_p, cord_t x, cord_t y)
|
||||
{
|
||||
cord_t w = area_get_width(area_p);
|
||||
@ -94,10 +110,10 @@ uint32_t area_get_size(const area_t * area_p)
|
||||
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p)
|
||||
{
|
||||
/* Get the smaller area from 'a1_p' and 'a2_p' */
|
||||
res_p->x1 = max(a1_p->x1, a2_p->x1);
|
||||
res_p->y1 = max(a1_p->y1, a2_p->y1);
|
||||
res_p->x2 = min(a1_p->x2, a2_p->x2);
|
||||
res_p->y2 = min(a1_p->y2, a2_p->y2);
|
||||
res_p->x1 = MATH_MAX(a1_p->x1, a2_p->x1);
|
||||
res_p->y1 = MATH_MAX(a1_p->y1, a2_p->y1);
|
||||
res_p->x2 = MATH_MIN(a1_p->x2, a2_p->x2);
|
||||
res_p->y2 = MATH_MIN(a1_p->y2, a2_p->y2);
|
||||
|
||||
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
|
||||
bool union_ok = true;
|
||||
@ -117,10 +133,10 @@ bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p)
|
||||
*/
|
||||
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p)
|
||||
{
|
||||
a_res_p->x1 = min(a1_p->x1, a2_p->x1);
|
||||
a_res_p->y1 = min(a1_p->y1, a2_p->y1);
|
||||
a_res_p->x2 = max(a1_p->x2, a2_p->x2);
|
||||
a_res_p->y2 = max(a1_p->y2, a2_p->y2);
|
||||
a_res_p->x1 = MATH_MIN(a1_p->x1, a2_p->x1);
|
||||
a_res_p->y1 = MATH_MIN(a1_p->y1, a2_p->y1);
|
||||
a_res_p->x2 = MATH_MAX(a1_p->x2, a2_p->x2);
|
||||
a_res_p->y2 = MATH_MAX(a1_p->y2, a2_p->y2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +162,8 @@ bool area_is_point_on(const area_t * a_p, const point_t * p_p)
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts */
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool area_is_on(const area_t * a1_p, const area_t * a2_p)
|
||||
{
|
||||
/*Two area are on each other if... */
|
||||
|
@ -41,31 +41,115 @@ typedef struct
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2);
|
||||
|
||||
/**
|
||||
* Copy an area
|
||||
* @param dest pointer to the destination area
|
||||
* @param src pointer to the source area
|
||||
*/
|
||||
static void inline area_cpy(area_t * dest, const area_t * src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(area_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the width of the area (if x1 == x2 -> width = 1)
|
||||
*/
|
||||
static inline cord_t area_get_width(const area_t * area_p)
|
||||
{
|
||||
return area_p->x2 - area_p->x1 + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the height of the area (if y1 == y2 -> height = 1)
|
||||
*/
|
||||
static inline cord_t area_get_height(const area_t * area_p)
|
||||
{
|
||||
return area_p->y2 - area_p->y1 + 1;
|
||||
}
|
||||
|
||||
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2);
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void area_set_width(area_t * area_p, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void area_set_height(area_t * area_p, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void area_set_pos(area_t * area_p, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t area_get_size(const area_t * area_p);
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored her
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool area_is_point_on(const area_t * a_p, const point_t * p_p);
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool area_is_on(const area_t * a1_p, const area_t * a2_p);
|
||||
bool area_is_in(const area_t * a_in, const area_t * a_holder);
|
||||
|
||||
/**
|
||||
* Check if an area is fully on an other
|
||||
* @param ain_p pointer to an area which could be on aholder_p
|
||||
* @param aholder pointer to an area which could involve ain_p
|
||||
* @return
|
||||
*/
|
||||
bool area_is_in(const area_t * ain_p, const area_t * aholder_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -40,8 +40,27 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the circle drawing
|
||||
* @param c pointer to a point. The coordinates will be calculated here
|
||||
* @param tmp point to a variable. It will store temporary data
|
||||
* @param radius radius of the circle
|
||||
*/
|
||||
void circ_init(point_t * c, cord_t * tmp, cord_t radius);
|
||||
|
||||
/**
|
||||
* Test the circle drawing is ready or not
|
||||
* @param c same as in circ_init
|
||||
* @return true if the circle is not ready yet
|
||||
*/
|
||||
bool circ_cont(point_t * c);
|
||||
|
||||
/**
|
||||
* Get the next point from the circle
|
||||
* @param c same as in circ_init. The next point stored here.
|
||||
* @param tmp same as in circ_init.
|
||||
*/
|
||||
void circ_next(point_t * c, cord_t * tmp);
|
||||
|
||||
/**********************
|
||||
|
@ -6,6 +6,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_misc/fonts/symbol_30.h>
|
||||
#include <stddef.h>
|
||||
#include "font.h"
|
||||
#include "fonts/dejavu_8.h"
|
||||
@ -108,6 +109,7 @@ const font_t * font_get(font_types_t font_id)
|
||||
font_p = symbol_30_get_dsc();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_60 != 0
|
||||
case FONT_SYMBOL_60:
|
||||
font_p = symbol_60_get_dsc();
|
||||
@ -120,6 +122,40 @@ const font_t * font_get(font_types_t font_id)
|
||||
return font_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return pointer to the bitmap of the letter
|
||||
*/
|
||||
const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter)
|
||||
{
|
||||
if(letter < font_p->start_ascii || letter >= font_p->start_ascii + font_p->letter_cnt) return NULL;
|
||||
|
||||
uint32_t index = (letter - font_p->start_ascii) * font_p->height_row * font_p->width_byte;
|
||||
return &font_p->bitmaps_a[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t font_get_width(const font_t * font_p, uint8_t letter)
|
||||
{
|
||||
if(letter < font_p->start_ascii) return 0;
|
||||
|
||||
letter -= font_p->start_ascii;
|
||||
uint8_t w = 0;
|
||||
if(letter < font_p->letter_cnt) {
|
||||
w = font_p->fixed_width != 0 ? font_p->fixed_width :
|
||||
font_p->width_bit_a[letter];
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -98,25 +98,22 @@ typedef struct
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const font_t * font_get(font_types_t letter);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* Get the font from its id
|
||||
* @param font_id: the id of a font (an element of font_types_t enum)
|
||||
* @return pointer to a font descriptor
|
||||
*/
|
||||
const font_t * font_get(font_types_t font_id);
|
||||
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return pointer to the bitmap of the letter
|
||||
*/
|
||||
static inline const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter)
|
||||
{
|
||||
if(letter < font_p->start_ascii || letter >= font_p->start_ascii + font_p->letter_cnt) return NULL;
|
||||
|
||||
uint32_t index = (letter - font_p->start_ascii) * font_p->height_row * font_p->width_byte;
|
||||
return &font_p->bitmaps_a[index];
|
||||
}
|
||||
const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter);
|
||||
|
||||
/**
|
||||
* Get the height of a font
|
||||
@ -128,24 +125,19 @@ static inline uint8_t font_get_height(const font_t * font_p)
|
||||
return font_p->height_row;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
static inline uint8_t font_get_width(const font_t * font_p, uint8_t letter)
|
||||
{
|
||||
if(letter < font_p->start_ascii) return 0;
|
||||
|
||||
letter -= font_p->start_ascii;
|
||||
uint8_t w = 0;
|
||||
if(letter < font_p->letter_cnt) {
|
||||
w = font_p->fixed_width != 0 ? font_p->fixed_width :
|
||||
font_p->width_bit_a[letter];
|
||||
}
|
||||
uint8_t font_get_width(const font_t * font_p, uint8_t letter);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "lv_conf.h"
|
||||
#if USE_FONT_SYMBOL_30 != 0
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../font.h"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include "../font.h"
|
||||
|
||||
static const uint8_t symbol_60_bitmaps[12480] =
|
||||
static const uint8_t symbol_60_bitmaps[12480] =
|
||||
{
|
||||
// ASCII: 97, char width: 60
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ------------------------------------------------------------....
|
||||
@ -1619,15 +1619,16 @@ static const uint8_t symbol_60_bitmaps[12480] =
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ----------------------------------------------------------------
|
||||
};
|
||||
|
||||
static const uint8_t symbol_60_widths[26] =
|
||||
|
||||
static const uint8_t symbol_60_widths[26] =
|
||||
{
|
||||
60, 51, 64, 47, 51, 51, 60, 47,
|
||||
60, 43, 43, 60, 34, 34, 47, 60,
|
||||
49, 59, 59, 59, 59, 59, 60, 51,
|
||||
51, 68,
|
||||
60, 51, 64, 47, 51, 51, 60, 47,
|
||||
60, 43, 43, 60, 34, 34, 47, 60,
|
||||
49, 59, 59, 59, 59, 59, 60, 51,
|
||||
51, 68,
|
||||
};
|
||||
|
||||
static const font_t symbol_60_dsc =
|
||||
static const font_t symbol_60_dsc =
|
||||
{
|
||||
26, // Letter count
|
||||
97, // First ascii code
|
||||
@ -1644,4 +1645,4 @@ const font_t * symbol_60_get_dsc(void)
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -6,11 +6,9 @@
|
||||
#include "lv_conf.h"
|
||||
#if USE_FONT_SYMBOL_60 != 0
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../font.h"
|
||||
|
||||
|
||||
const font_t * symbol_60_get_dsc(void);
|
||||
|
||||
#endif
|
||||
|
41
lv_misc/fonts/symbol_def.h
Normal file
41
lv_misc/fonts/symbol_def.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef SYMBOL_DEF_H
|
||||
#define SYMBOL_DEF_H
|
||||
|
||||
/*Use ISO8859-1 encoding in the IDE*/
|
||||
|
||||
#include "lv_conf.h"
|
||||
#if USE_FONT_SYMBOL_30 != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../font.h"
|
||||
|
||||
#define SYMBOL_DRIVE "a"
|
||||
#define SYMBOL_FILE "b"
|
||||
#define SYMBOL_FOLDER "c"
|
||||
#define SYMBOL_DELETE "d"
|
||||
#define SYMBOL_SAVE "e"
|
||||
#define SYMBOL_EDIT "f"
|
||||
#define SYMBOL_OK "g"
|
||||
#define SYMBOL_CLOSE "h"
|
||||
#define SYMBOL_DOWN "i"
|
||||
#define SYMBOL_LEFT "j"
|
||||
#define SYMBOL_RIGHT "k"
|
||||
#define SYMBOL_UP "l"
|
||||
#define SYMBOL_BT "m"
|
||||
#define SYMBOL_THERM "n"
|
||||
#define SYMBOL_GPS "o"
|
||||
#define SYMBOL_WARN "p"
|
||||
#define SYMBOL_INFO "q"
|
||||
#define SYMBOL_BATT1 "r"
|
||||
#define SYMBOL_BATT2 "s"
|
||||
#define SYMBOL_BATT3 "t"
|
||||
#define SYMBOL_BATT4 "u"
|
||||
#define SYMBOL_BATTCH "v"
|
||||
#define SYMBOL_HELP "w"
|
||||
#define SYMBOL_POWER "x"
|
||||
#define SYMBOL_SETUP "y"
|
||||
#define SYMBOL_WIFI "z"
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*SYMBOL_DEF_H*/
|
@ -35,15 +35,28 @@ static bool txt_is_break_char(char letter);
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get size of a text
|
||||
* @param size_res pointer to a 'point_t' variable to store the result
|
||||
* @param text pointer to a text
|
||||
* @param font pinter to font of the text
|
||||
* @param letter_space letter space of the text
|
||||
* @param line_space line space of the text
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set LV_CORD_MAX to avoid line breaks
|
||||
*/
|
||||
void txt_get_size(point_t * size_res, const char * text, const font_t * font,
|
||||
uint16_t letter_space, uint16_t line_space, cord_t max_width)
|
||||
{
|
||||
size_res->x = 0;
|
||||
size_res->y = 0;
|
||||
|
||||
if(text == NULL) return;
|
||||
if(font == NULL) return;
|
||||
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
cord_t act_line_length;
|
||||
uint8_t letter_height = font_get_height(font);
|
||||
size_res->x = 0;
|
||||
size_res->y = 0;
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
while (text[line_start] != '\0')
|
||||
@ -56,7 +69,7 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
|
||||
act_line_length = txt_get_width(&text[line_start], new_line_start - line_start,
|
||||
font, letter_space);
|
||||
|
||||
size_res->x = max(act_line_length, size_res->x);
|
||||
size_res->x = MATH_MAX(act_line_length, size_res->x);
|
||||
line_start = new_line_start;
|
||||
}
|
||||
|
||||
@ -73,14 +86,17 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
|
||||
/**
|
||||
* Get the next line of text. Check line length and break chars too.
|
||||
* @param txt a '\0' terminated string
|
||||
* @param font_p pointer to a font
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param max_l max line length
|
||||
* @return the index of the first char of the new line
|
||||
*/
|
||||
uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
|
||||
uint16_t txt_get_next_line(const char * txt, const font_t * font,
|
||||
uint16_t letter_space, cord_t max_l)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
uint32_t i = 0;
|
||||
cord_t act_l = 0;
|
||||
uint16_t last_break = TXT_NO_BREAK_FOUND;
|
||||
@ -97,7 +113,7 @@ uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
|
||||
return i+1; /*Return with the first letter of the next line*/
|
||||
|
||||
} else { /*Check the actual length*/
|
||||
act_l += font_get_width(font_p, txt[i]);
|
||||
act_l += font_get_width(font, txt[i]);
|
||||
|
||||
/*If the txt is too long then finish, this is the line end*/
|
||||
if(act_l > max_l) {
|
||||
@ -133,26 +149,29 @@ uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
|
||||
* Give the length of a text with a given font
|
||||
* @param txt a '\0' terminate string
|
||||
* @param char_num number of characters in 'txt'
|
||||
* @param font_p pointer to a font
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter sapce
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
cord_t txt_get_width(const char * txt, uint16_t char_num,
|
||||
const font_t * font_p, uint16_t letter_space)
|
||||
const font_t * font, uint16_t letter_space)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
uint16_t i;
|
||||
cord_t len = 0;
|
||||
|
||||
if(char_num != 0) {
|
||||
for(i = 0; i < char_num; i++) {
|
||||
len += font_get_width(font_p, txt[i]);
|
||||
len += font_get_width(font, txt[i]);
|
||||
len += letter_space;
|
||||
}
|
||||
|
||||
/*Trim closing spaces */
|
||||
for(i = char_num - 1; i > 0; i--) {
|
||||
if(txt[i] == ' ') {
|
||||
len -= font_get_width(font_p, txt[i]);
|
||||
len -= font_get_width(font, txt[i]);
|
||||
len -= letter_space;
|
||||
} else {
|
||||
break;
|
||||
|
@ -26,10 +26,40 @@
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get size of a text
|
||||
* @param size_res pointer to a 'point_t' variable to store the result
|
||||
* @param text pointer to a text
|
||||
* @param font pinter to font of the text
|
||||
* @param letter_space letter space of the text
|
||||
* @param line_space line space of the text
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set LV_CORD_MAX to avoid line breaks
|
||||
*/
|
||||
void txt_get_size(point_t * size_res, const char * text, const font_t * font,
|
||||
uint16_t letter_space, uint16_t line_space, cord_t max_width);
|
||||
uint16_t txt_get_next_line(const char * txt, const font_t * font_p, uint16_t letter_space, cord_t max_l);
|
||||
cord_t txt_get_width(const char * txt, uint16_t char_num, const font_t * font_p, uint16_t letter_space);
|
||||
uint16_t letter_space, uint16_t line_space, cord_t max_width);
|
||||
|
||||
/**
|
||||
* Get the next line of text. Check line length and break chars too.
|
||||
* @param txt a '\0' terminated string
|
||||
* @param font_p pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param max_l max line length
|
||||
* @return the index of the first char of the new line
|
||||
*/
|
||||
uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
|
||||
uint16_t letter_space, cord_t max_l);
|
||||
|
||||
/**
|
||||
* Give the length of a text with a given font
|
||||
* @param txt a '\0' terminate string
|
||||
* @param char_num number of characters in 'txt'
|
||||
* @param font_p pointer to a font
|
||||
* @param letter_space letter sapce
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
cord_t txt_get_width(const char * txt, uint16_t char_num,
|
||||
const font_t * font_p, uint16_t letter_space);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -74,44 +74,55 @@ void lv_dispi_reset(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last point on display input
|
||||
* @param dispi_p pointer to a display input
|
||||
* @param point_p pointer to a point to store the result
|
||||
* Reset the long press state of a display input
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_get_point(lv_dispi_t * dispi_p, point_t * point_p)
|
||||
void lv_dispi_reset_lpr(lv_dispi_t * dispi)
|
||||
{
|
||||
point_p->x = dispi_p->act_point.x;
|
||||
point_p->y = dispi_p->act_point.y;
|
||||
dispi->long_press_sent = 0;
|
||||
dispi->lpr_rep_time_stamp = systick_get();
|
||||
dispi->press_time_stamp = systick_get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last point on display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the result
|
||||
*/
|
||||
void lv_dispi_get_point(lv_dispi_t * dispi, point_t * point)
|
||||
{
|
||||
point->x = dispi->act_point.x;
|
||||
point->y = dispi->act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is dragging on display input or not
|
||||
* @param dispi_p pointer to a display input
|
||||
* @param dispi pointer to a display input
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_dispi_is_dragging(lv_dispi_t * dispi_p)
|
||||
bool lv_dispi_is_dragging(lv_dispi_t * dispi)
|
||||
{
|
||||
return dispi_p->drag_in_prog == 0 ? false : true;
|
||||
return dispi->drag_in_prog == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vector of dragging on a display input
|
||||
* @param dispi_p pointer to a display input
|
||||
* @param point_p pointer to a point to store the vector
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
void lv_dispi_get_vect(lv_dispi_t * dispi_p, point_t * point_p)
|
||||
void lv_dispi_get_vect(lv_dispi_t * dispi, point_t * point)
|
||||
{
|
||||
point_p->x = dispi_p->vect.x;
|
||||
point_p->y = dispi_p->vect.y;
|
||||
point->x = dispi->vect.x;
|
||||
point->y = dispi->vect.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing until the next release
|
||||
* @param dispi_p pointer to a display input
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_wait_release(lv_dispi_t * dispi_p)
|
||||
void lv_dispi_wait_release(lv_dispi_t * dispi)
|
||||
{
|
||||
dispi_p->wait_release = 1;
|
||||
dispi->wait_release = 1;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -48,12 +48,49 @@ typedef lv_action_res_t ( * lv_action_t) (struct __LV_OBJ_T * obj, lv_dispi_t *
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the display input subsystem
|
||||
*/
|
||||
void lv_dispi_init(void);
|
||||
|
||||
/**
|
||||
* Reset all display inputs
|
||||
*/
|
||||
void lv_dispi_reset(void);
|
||||
bool lv_dispi_is_dragging(lv_dispi_t * dispi_p);
|
||||
void lv_dispi_get_point(lv_dispi_t * dispi_p, point_t * point_p);
|
||||
void lv_dispi_get_vect(lv_dispi_t * dispi_p, point_t * point_p);
|
||||
void lv_dispi_wait_release(lv_dispi_t * dispi_p);
|
||||
|
||||
/**
|
||||
* Reset the long press state of a display input
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_reset_lpr(lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Get the last point on display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the result
|
||||
*/
|
||||
void lv_dispi_get_point(lv_dispi_t * dispi, point_t * point);
|
||||
|
||||
/**
|
||||
* Check if there is dragging on display input or not
|
||||
* @param dispi pointer to a display input
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_dispi_is_dragging(lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Get the vector of dragging on a display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
void lv_dispi_get_vect(lv_dispi_t * dispi, point_t * point);
|
||||
|
||||
/**
|
||||
* Do nothing until the next release
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_wait_release(lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
129
lv_obj/lv_obj.c
129
lv_obj/lv_obj.c
@ -105,64 +105,6 @@ void lv_init(void)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj)
|
||||
{
|
||||
/*Invalidate the object only if it belongs to the 'act_scr'*/
|
||||
lv_obj_t * act_scr_p = lv_scr_act();
|
||||
if(lv_obj_get_scr(obj) == act_scr_p) {
|
||||
/*Truncate recursively to the parents*/
|
||||
area_t area_trunc;
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
bool union_ok = true;
|
||||
/*Start with the original coordinates*/
|
||||
cord_t ext_size = obj->ext_size;
|
||||
area_cpy(&area_trunc, &obj->cords);
|
||||
area_trunc.x1 -= ext_size;
|
||||
area_trunc.y1 -= ext_size;
|
||||
area_trunc.x2 += ext_size;
|
||||
area_trunc.y2 += ext_size;
|
||||
|
||||
/*Check through all parents*/
|
||||
while(par != NULL) {
|
||||
union_ok = area_union(&area_trunc, &area_trunc, &par->cords);
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
||||
if(union_ok != false) lv_inv_area(&area_trunc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_inv(obj);
|
||||
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_inv(obj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pinter to a style. Only objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_all(void * style)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(scr_ll, i) {
|
||||
lv_style_refr_core(style, i);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* Create and delete
|
||||
*-------------------*/
|
||||
@ -410,6 +352,42 @@ lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p)
|
||||
|
||||
return style_p;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj)
|
||||
{
|
||||
/*Invalidate the object only if it belongs to the 'act_scr'*/
|
||||
lv_obj_t * act_scr_p = lv_scr_act();
|
||||
if(lv_obj_get_scr(obj) == act_scr_p) {
|
||||
/*Truncate recursively to the parents*/
|
||||
area_t area_trunc;
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
bool union_ok = true;
|
||||
/*Start with the original coordinates*/
|
||||
cord_t ext_size = obj->ext_size;
|
||||
area_cpy(&area_trunc, &obj->cords);
|
||||
area_trunc.x1 -= ext_size;
|
||||
area_trunc.y1 -= ext_size;
|
||||
area_trunc.x2 += ext_size;
|
||||
area_trunc.y2 += ext_size;
|
||||
|
||||
/*Check through all parents*/
|
||||
while(par != NULL) {
|
||||
union_ok = area_union(&area_trunc, &area_trunc, &par->cords);
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
||||
if(union_ok != false) lv_inv_area(&area_trunc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -459,9 +437,9 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||
lv_obj_inv(obj);
|
||||
}
|
||||
|
||||
/*-------------------------------------------
|
||||
* Coordinate set (cord_chk_f will be called)
|
||||
* -----------------------------------------*/
|
||||
/*--------------------
|
||||
* Coordinate set
|
||||
* ------------------*/
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent)
|
||||
@ -895,6 +873,33 @@ void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa)
|
||||
lv_obj_inv(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_inv(obj);
|
||||
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_inv(obj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pinter to a style. Only objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_all(void * style)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(scr_ll, i) {
|
||||
lv_style_refr_core(style, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-----------------
|
||||
* Attribute set
|
||||
*----------------*/
|
||||
@ -1425,7 +1430,7 @@ bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot)
|
||||
* @param obj pointer to an object
|
||||
* @return the signal function
|
||||
*/
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj)
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj)
|
||||
{
|
||||
return obj->signal_f;
|
||||
}
|
||||
|
551
lv_obj/lv_obj.h
551
lv_obj/lv_obj.h
@ -28,8 +28,8 @@
|
||||
#error "LV: LV_DOWNSCALE can be only 1 or 2"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && LV_DOWNSCALE != 1
|
||||
#error "LV: If LV_VDB_SIZE == 0 then LV_DOWNSCALE must be 1, LV_UPSCALE_MAP 0, LV_UPSCALE_STYLE 0"
|
||||
#if LV_VDB_SIZE == 0 && LV_ANTIALIAS != 0
|
||||
#error "LV: If LV_VDB_SIZE == 0 the antialaissing must be disabled"
|
||||
#endif
|
||||
|
||||
/*New defines*/
|
||||
@ -175,99 +175,526 @@ typedef enum
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the 'lv' library.
|
||||
*/
|
||||
void lv_init(void);
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pinter to a style. Only objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_all(void * style);
|
||||
|
||||
/*Create and delete*/
|
||||
/**
|
||||
* Create a basic object
|
||||
* @param parent pointer to a parent object.
|
||||
* If NULL then a screen will be created
|
||||
* @param copy pointer to a base object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the new object
|
||||
*/
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Delete 'obj' and all of its children
|
||||
* @param obj
|
||||
*/
|
||||
void lv_obj_del(lv_obj_t * obj);
|
||||
|
||||
/*Virtual functions*/
|
||||
/**
|
||||
* Signal function of the basic object
|
||||
* @param obj pointer to an object
|
||||
* @param sign signal type
|
||||
* @param param parameter for the signal (depends on signal type)
|
||||
* @return false: the object become invalid (e.g. deleted)
|
||||
*/
|
||||
bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/*SETTER FUNCTIONS*/
|
||||
/*Parent/children set*/
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
|
||||
/*Coordinate set (set_cord_f will be called)*/
|
||||
void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
void lv_obj_set_x(lv_obj_t * obj, cord_t x);
|
||||
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x);
|
||||
void lv_obj_set_y(lv_obj_t * obj, cord_t y);
|
||||
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
void lv_obj_set_width(lv_obj_t * obj, cord_t w);
|
||||
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w);
|
||||
void lv_obj_set_height(lv_obj_t * obj, cord_t h);
|
||||
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);
|
||||
/*Appearance set*/
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_opa(lv_obj_t * obj, opa_t opa);
|
||||
void lv_obj_set_opar(lv_obj_t * obj, opa_t opa);
|
||||
/*Attribute set*/
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
|
||||
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
|
||||
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
/*Other set*/
|
||||
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style);
|
||||
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size);
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t anim, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *));
|
||||
/**
|
||||
* Return with a pointer to built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_objs_builtin_t enum
|
||||
* @param copy_p copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_objs_t style
|
||||
*/
|
||||
lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p);
|
||||
|
||||
/*GETTER FUNCTIONS*/
|
||||
/*Screen get*/
|
||||
lv_obj_t * lv_scr_act(void);
|
||||
/**
|
||||
* Load a new screen
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr);
|
||||
/*Parent/children get*/
|
||||
|
||||
/**
|
||||
* Set a new parent for an object. Its relative position will be the same.
|
||||
* @param obj pointer to an object
|
||||
* @param parent pointer to the new parent object
|
||||
*/
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent)
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side of the parent
|
||||
* @param y new distance from the top of the parent
|
||||
*/
|
||||
void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent).
|
||||
* The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent
|
||||
*/
|
||||
void lv_obj_set_x(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object.
|
||||
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent
|
||||
*/
|
||||
void lv_obj_set_y(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object.
|
||||
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the size of an object
|
||||
* @param obj pointer to an object
|
||||
* @param w new width
|
||||
* @param h new height
|
||||
*/
|
||||
void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the size of an object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @param w new width
|
||||
*/
|
||||
void lv_obj_set_width(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the width of an object. The width will be upscaled to compensate LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @param h new height
|
||||
*/
|
||||
void lv_obj_set_height(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the height of an object. The height will be upscaled to compensate LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_mod x coordinate shift after alignment
|
||||
* @param y_mod y coordinate shift after alignment
|
||||
*/
|
||||
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Align an object to an other object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_mod x coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y_mod y coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Set the extended size of an object
|
||||
* @param obj pointer to an object
|
||||
* @param ext_size the extended size
|
||||
*/
|
||||
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);
|
||||
|
||||
/**
|
||||
* Set a new style for an object
|
||||
* @param obj pointer to an object
|
||||
* @param style_p pointer to the new style
|
||||
*/
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style);
|
||||
|
||||
/**
|
||||
* Isolate the style of an object. In other words a unique style will be created
|
||||
* for this object which can be freely modified independently from the style of the
|
||||
* other objects.
|
||||
*/
|
||||
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size);
|
||||
|
||||
/**
|
||||
* Set the opacity of an object
|
||||
* @param obj pointer to an object
|
||||
* @param opa 0 (transparent) .. 255(fully cover)
|
||||
*/
|
||||
void lv_obj_set_opa(lv_obj_t * obj, uint8_t opa);
|
||||
|
||||
/**
|
||||
* Set the opacity of an object and all of its children
|
||||
* @param obj pointer to an object
|
||||
* @param opa 0 (transparent) .. 255(fully cover)
|
||||
*/
|
||||
void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa);
|
||||
|
||||
/**
|
||||
* Hide an object. It won't be visible and clickable.
|
||||
* @param obj pointer to an object
|
||||
* @param en true: hide the object
|
||||
*/
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable or disable the clicking of an object
|
||||
* @param obj pointer to an object
|
||||
* @param en true: make the object clickable
|
||||
*/
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable to bring this object to the foreground if it
|
||||
* or any of its children is clicked
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable the auto top feature
|
||||
*/
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable the dragging of an object
|
||||
* @param obj pointer to an object
|
||||
* @param en true: make the object dragable
|
||||
*/
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable the throwing of an object after is is dragged
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable the drag throw
|
||||
*/
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable to use parent for drag related operations.
|
||||
* If trying to drag the object the parent will be moved instead
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable the 'drag parent' for the object
|
||||
*/
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Set a bit or bits in the protect filed
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Clear a bit or bits in the protect filed
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Set the signal function of an object.
|
||||
* Always call the previous signal function in the new.
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new signal function
|
||||
*/
|
||||
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
|
||||
|
||||
/**
|
||||
* Set a new design function for an object
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new design function
|
||||
*/
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
|
||||
/**
|
||||
* Allocate a new ext. data for an object
|
||||
* @param obj pointer to an object
|
||||
* @param ext_size the size of the new ext. data
|
||||
* @return Normal pointer to the allocated ext
|
||||
*/
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
|
||||
/**
|
||||
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_num the new free number
|
||||
*/
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
|
||||
/**
|
||||
* Set an application specific pointer for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_p the new free pinter
|
||||
*/
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
|
||||
/**
|
||||
* Animate an object
|
||||
* @param obj pointer to an object to animate
|
||||
* @param type type of animation from 'lv_anim_builtin_t'. 'OR' it with ANIM_IN or ANIM_OUT
|
||||
* @param time time of animation in milliseconds
|
||||
* @param delay delay before the animation in milliseconds
|
||||
* @param cb a function to call when the animation is ready
|
||||
*/
|
||||
void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *));
|
||||
|
||||
/**
|
||||
* Return with the actual screen
|
||||
* @return pointer to to the actual screen object
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void);
|
||||
|
||||
/**
|
||||
* Return with the screen of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a screen
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Returns with the parent of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to the parent of 'obj'
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Iterate through the children of an object
|
||||
* @param obj pointer to an object
|
||||
* @param child NULL at first call to get the next children
|
||||
* and the previous return value later
|
||||
* @return the child after 'act_child' or NULL if no more child
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child);
|
||||
|
||||
/**
|
||||
* Count the children of an object (only children directly on 'obj')
|
||||
* @param obj pointer to an object
|
||||
* @return children number of 'obj'
|
||||
*/
|
||||
uint16_t lv_obj_get_child_num(lv_obj_t * obj);
|
||||
|
||||
/*Coordinate get*/
|
||||
/**
|
||||
* Copy the coordinates of an object to an area
|
||||
* @param obj pointer to an object
|
||||
* @param cords_p pointer to an area to store the coordinates
|
||||
*/
|
||||
void lv_obj_get_cords(lv_obj_t * obj, area_t * cords_p);
|
||||
|
||||
/**
|
||||
* Get the x coordinate of object
|
||||
* @param obj pointer to an object
|
||||
* @return distance of 'obj' from the left side of its parent
|
||||
*/
|
||||
cord_t lv_obj_get_x(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the y coordinate of object
|
||||
* @param obj pointer to an object
|
||||
* @return distance of 'obj' from the top of its parent
|
||||
*/
|
||||
cord_t lv_obj_get_y(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the width
|
||||
*/
|
||||
cord_t lv_obj_get_width(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the height
|
||||
*/
|
||||
cord_t lv_obj_get_height(lv_obj_t * obj);
|
||||
/*Appearance get*/
|
||||
bool lv_obj_get_hidden(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the extended size attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the extended size attribute
|
||||
*/
|
||||
cord_t lv_obj_getext_size(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the style pointer of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
void * lv_obj_get_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the opacity of an object
|
||||
* @param obj pointer to an object
|
||||
* @return 0 (transparent) .. 255 (fully cover)
|
||||
*/
|
||||
opa_t lv_obj_get_opa(lv_obj_t * obj);
|
||||
/*Attribute get*/
|
||||
|
||||
/**
|
||||
* Get the hidden attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the object is hidden
|
||||
*/
|
||||
bool lv_obj_get_hidden(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the click enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the object is clickable
|
||||
*/
|
||||
bool lv_obj_get_click(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the top enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the auto top feture is enabled
|
||||
*/
|
||||
bool lv_obj_get_top(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drag enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the object is dragable
|
||||
*/
|
||||
bool lv_obj_get_drag(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drag thow enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: drag throw is enabled
|
||||
*/
|
||||
bool lv_obj_get_drag_throw(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drag parent attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: drag parent is enabled
|
||||
*/
|
||||
bool lv_obj_get_drag_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the style isolation attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
bool lv_obj_get_style_iso(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the protect field of an object
|
||||
* @param obj pointer to an object
|
||||
* @return protect field ('OR'ed values of lv_obj_prot_t)
|
||||
*/
|
||||
uint8_t lv_obj_get_protect(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check at least one bit of a given protect bitfield is set
|
||||
* @param obj pointer to an object
|
||||
* @param prot protect bits to test ('OR'ed values of lv_obj_prot_t)
|
||||
* @return false: none of the given bits are set, true: at least one bit is set
|
||||
*/
|
||||
bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/*Virtual functions get*/
|
||||
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj);
|
||||
/*Other get*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj);
|
||||
void * lv_obj_get_style(lv_obj_t * obj);
|
||||
uint8_t lv_obj_get_free_num(lv_obj_t * obj);
|
||||
void * lv_obj_get_free_p(lv_obj_t * obj);
|
||||
/**
|
||||
* Get the signal function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the signal function
|
||||
*/
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj);
|
||||
|
||||
lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p);
|
||||
/**
|
||||
* Get the design function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the design function
|
||||
*/
|
||||
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the ext pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the ext pointer but not the dynamic version
|
||||
* Use it as ext->data1, and NOT da(ext)->data1
|
||||
*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the free number
|
||||
* @param obj pointer to an object
|
||||
* @return the free number
|
||||
*/
|
||||
uint8_t lv_obj_get_free_num(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the free pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the free pointer
|
||||
*/
|
||||
void * lv_obj_get_free_p(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -32,9 +32,18 @@
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the screen refresh subsystem
|
||||
*/
|
||||
void lv_refr_init(void);
|
||||
|
||||
/**
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
*/
|
||||
void lv_inv_area(const area_t * area_p);
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
**********************/
|
||||
|
@ -56,37 +56,48 @@ void lv_vdb_flush(void)
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 , vdb.vdb_area.y1, vdb.vdb_area.x2, vdb.vdb_area.y2);
|
||||
disp_map(DISP_ID_ALL, vdb.buf);
|
||||
#else
|
||||
color_t row_buf[LV_HOR_RES / LV_DOWNSCALE];
|
||||
color_t * row_buf_p;
|
||||
/* Get the average of 2x2 pixels and put the result back to the VDB
|
||||
* The reading goes much faster then the write back
|
||||
* so useful data won't be overwritten
|
||||
* Example:
|
||||
* -----------------------------
|
||||
* in1_buf |2,2|6,8| 3,7
|
||||
* in2_buf |4,4|7,7| 1,2
|
||||
* --------- ==>
|
||||
* in1_buf |1,1|1,3|
|
||||
* in2_buf |1,1|1,3|
|
||||
* */
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
cord_t w = area_get_width(&vdb.vdb_area);
|
||||
cord_t i;
|
||||
color_t * buf_p = vdb.buf;
|
||||
for(y = vdb.vdb_area.y1 >> 1; y <= vdb.vdb_area.y2 >> 1; y ++) {
|
||||
i = 0;
|
||||
row_buf_p = row_buf;
|
||||
for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 2, i += 2) {
|
||||
row_buf_p->red = (buf_p[i].red +
|
||||
buf_p[i + 1].red +
|
||||
buf_p[i + w].red +
|
||||
buf_p[i + w + 1].red) >> 2;
|
||||
row_buf_p->green = (buf_p[i].green +
|
||||
buf_p[i + 1].green +
|
||||
buf_p[i + w].green +
|
||||
buf_p[i + w + 1].green) >> 2;
|
||||
row_buf_p->blue = (buf_p[i].blue +
|
||||
buf_p[i + 1].blue +
|
||||
buf_p[i + w].blue +
|
||||
buf_p[i + w + 1].blue) >> 2;
|
||||
color_t * in1_buf = vdb.buf; /*Pointer to the first row*/
|
||||
color_t * in2_buf = vdb.buf + w; /*Pointer to the second row*/
|
||||
color_t * out_buf = vdb.buf; /*Store the result here*/
|
||||
for(y = vdb.vdb_area.y1; y < vdb.vdb_area.y2; y += 2) {
|
||||
for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 2) {
|
||||
/*Get the average of 2x2 red*/
|
||||
out_buf->red = (in1_buf->red + (in1_buf + 1)->red +
|
||||
in2_buf->red + (in2_buf+ 1)->red) >> 2;
|
||||
/*Get the average of 2x2 green*/
|
||||
out_buf->green = (in1_buf->green + (in1_buf + 1)->green +
|
||||
in2_buf->green + (in2_buf + 1)->green) >> 2;
|
||||
/*Get the average of 2x2 blue*/
|
||||
out_buf->blue = (in1_buf->blue + (in1_buf + 1)->blue +
|
||||
in2_buf->blue + (in2_buf + 1)->blue) >> 2;
|
||||
|
||||
row_buf_p++;
|
||||
in1_buf+=2; /*Skip the next pixel because it is already used above*/
|
||||
in2_buf+=2;
|
||||
out_buf++;
|
||||
}
|
||||
buf_p += LV_DOWNSCALE * w;
|
||||
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 1, y, vdb.vdb_area.x2 >> 1, y);
|
||||
disp_map(DISP_ID_ALL, row_buf);
|
||||
/*2 row is ready so go the next 2*/
|
||||
in1_buf += w; /*Skip the next row because it is processed from in2_buf*/
|
||||
in2_buf += w;
|
||||
}
|
||||
|
||||
/* Now the full the VDB is filtered and the result is stored in the first quarter of it
|
||||
* Write out the filtered map to the display*/
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 1, vdb.vdb_area.y1 >> 1, vdb.vdb_area.x2 >> 1, vdb.vdb_area.y2 >> 1);
|
||||
disp_map(DISP_ID_ALL, vdb.buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,17 @@ typedef struct
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the vdb variable
|
||||
* @return pointer to the vdb variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void);
|
||||
|
||||
/**
|
||||
* Flush the content of the vdb
|
||||
*/
|
||||
void lv_vdb_flush(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -425,7 +425,7 @@ static void lv_btns_init(void)
|
||||
/*Default style*/
|
||||
lv_btns_def.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x60, 0x88, 0xb0);
|
||||
lv_btns_def.gcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xa0, 0xc0, 0xe0);
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xff, 0xff, 0xff);
|
||||
lv_btns_def.lcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x30, 0x40, 0x50);
|
||||
lv_btns_def.flags[LV_BTN_STATE_REL].light_en = 0;
|
||||
lv_btns_def.flags[LV_BTN_STATE_REL].transp = 0;
|
||||
@ -515,7 +515,7 @@ static void lv_btns_init(void)
|
||||
lv_btns_border.flags[LV_BTN_STATE_TGL_REL].light_en = 0;
|
||||
lv_btns_border.flags[LV_BTN_STATE_TGL_PR].light_en = 0;
|
||||
lv_btns_border.flags[LV_BTN_STATE_INA].light_en = 0;
|
||||
lv_btns_border.rects.bwidth = 2 * LV_DOWNSCALE;
|
||||
lv_btns_border.rects.bwidth = 1 * LV_DOWNSCALE;
|
||||
lv_btns_border.rects.bopa = 50;
|
||||
lv_btns_border.rects.round = 4 * LV_DOWNSCALE;
|
||||
lv_btns_border.rects.hpad = 10 * LV_DOWNSCALE;
|
||||
|
131
lv_objx/lv_btn.h
131
lv_objx/lv_btn.h
@ -38,67 +38,134 @@ typedef enum
|
||||
LV_BTN_STATE_NUM,
|
||||
}lv_btn_state_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t light_en :1;
|
||||
uint8_t transp :1;
|
||||
uint8_t empty :1;
|
||||
}lv_btns_bits_t;
|
||||
|
||||
/*Style of button*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t rects; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
color_t mcolor[LV_BTN_STATE_NUM];
|
||||
color_t gcolor[LV_BTN_STATE_NUM];
|
||||
color_t bcolor[LV_BTN_STATE_NUM];
|
||||
color_t lcolor[LV_BTN_STATE_NUM];
|
||||
lv_btns_bits_t flags[LV_BTN_STATE_NUM];
|
||||
}lv_btns_t;
|
||||
|
||||
/*Built-in styles of button*/
|
||||
typedef enum
|
||||
{
|
||||
LV_BTNS_DEF,
|
||||
LV_BTNS_TRANSP,
|
||||
LV_BTNS_BORDER,
|
||||
}lv_btns_builtin_t;
|
||||
|
||||
/*Data of button*/
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t pr_action;
|
||||
lv_action_t rel_action;
|
||||
lv_action_t lpr_action;
|
||||
lv_action_t lpr_rep_action;
|
||||
|
||||
|
||||
lv_btn_state_t state;
|
||||
uint8_t tgl :1; /*1: Toggle enabled*/
|
||||
uint8_t lpr_exec :1; /*1: long press action executed (Not for user)*/
|
||||
}lv_btn_ext_t;
|
||||
|
||||
/*Bits of 'flag' in 'lv_btns_t'*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t light_en :1;
|
||||
uint8_t transp :1;
|
||||
uint8_t empty :1;
|
||||
}lv_btns_bits_t;
|
||||
|
||||
/*Style of button*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t rects; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
color_t mcolor[LV_BTN_STATE_NUM];
|
||||
color_t gcolor[LV_BTN_STATE_NUM];
|
||||
color_t bcolor[LV_BTN_STATE_NUM];
|
||||
color_t lcolor[LV_BTN_STATE_NUM];
|
||||
lv_btns_bits_t flags[LV_BTN_STATE_NUM];
|
||||
}lv_btns_t;
|
||||
|
||||
/*Built-in styles of button*/
|
||||
typedef enum
|
||||
{
|
||||
LV_BTNS_DEF,
|
||||
LV_BTNS_TRANSP,
|
||||
LV_BTNS_BORDER,
|
||||
}lv_btns_builtin_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
/*Create function*/
|
||||
|
||||
/**
|
||||
* Create a button objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a button object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button
|
||||
*/
|
||||
lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
|
||||
lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy);
|
||||
|
||||
/**
|
||||
* Enable the toggled states
|
||||
* @param btn pointer to a button object
|
||||
* @param tgl true: enable toggled states, false: disable
|
||||
*/
|
||||
void lv_btn_set_tgl(lv_obj_t * btn, bool tgl);
|
||||
|
||||
/**
|
||||
* Set the state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param state the new state of the button (from lv_btn_state_t enum)
|
||||
*/
|
||||
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_t pr_action);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is released
|
||||
* @param btn pointer to a button object
|
||||
* @param rel_action pointer to functionREL
|
||||
*/
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is long pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_t lpr_action);
|
||||
|
||||
/**
|
||||
* Set a function to called periodically after long press.
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_rep_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action);
|
||||
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn);
|
||||
/**
|
||||
* Get the current state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return the state of the button (from lv_btn_state_t enum)
|
||||
*/
|
||||
lv_btn_state_t lv_btn_get_state(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the toggle enable attribute of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return ture: toggle enabled, false: disabled
|
||||
*/
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_btns_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_btns_t style
|
||||
*/
|
||||
lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "lv_btnm.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/text.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -28,6 +29,7 @@
|
||||
|
||||
static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_t mode);
|
||||
static uint8_t lv_btnm_get_width_unit(const char * btn_str);
|
||||
static uint16_t lv_btnm_get_btn_from_point(lv_obj_t * btnm, point_t * p);
|
||||
static void lv_btnm_create_btns(lv_obj_t * btnm, const char ** map);
|
||||
static void lv_btnms_init(void);
|
||||
|
||||
@ -112,10 +114,10 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
uint16_t i;
|
||||
uint16_t new_btn;
|
||||
area_t btnm_area;
|
||||
area_t btn_area;
|
||||
point_t p;
|
||||
area_t btn_area;
|
||||
area_t btnm_cords;
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
dm_free(ext->btn_areas);
|
||||
@ -126,21 +128,31 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
break;
|
||||
case LV_SIGNAL_PRESSING:
|
||||
/*Search the pressed area*/
|
||||
ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
|
||||
lv_dispi_get_point(param, &p);
|
||||
lv_obj_get_cords(btnm, &btnm_cords);
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[i]);
|
||||
btn_area.x1 += btnm_cords.x1;
|
||||
btn_area.y1 += btnm_cords.y1;
|
||||
btn_area.x2 += btnm_cords.x1;
|
||||
btn_area.y2 += btnm_cords.y1;
|
||||
if(area_is_point_on(&btn_area, &p) != false) {
|
||||
ext->btn_pr = i;
|
||||
lv_obj_inv(btnm);
|
||||
break;
|
||||
}
|
||||
lv_dispi_get_point(param, &p);
|
||||
new_btn = lv_btnm_get_btn_from_point(btnm, &p);
|
||||
/*Invalidate to old and the new areas*/;
|
||||
lv_obj_get_cords(btnm, &btnm_area);
|
||||
if(new_btn != ext->btn_pr) {
|
||||
lv_dispi_reset_lpr(param);
|
||||
if(ext->btn_pr != LV_BTNM_BTN_PR_INVALID) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[ext->btn_pr]);
|
||||
btn_area.x1 += btnm_area.x1;
|
||||
btn_area.y1 += btnm_area.y1;
|
||||
btn_area.x2 += btnm_area.x1;
|
||||
btn_area.y2 += btnm_area.y1;
|
||||
lv_inv_area(&btn_area);
|
||||
}
|
||||
if(new_btn != LV_BTNM_BTN_PR_INVALID) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[new_btn]);
|
||||
btn_area.x1 += btnm_area.x1;
|
||||
btn_area.y1 += btnm_area.y1;
|
||||
btn_area.x2 += btnm_area.x1;
|
||||
btn_area.y2 += btnm_area.y1;
|
||||
lv_inv_area(&btn_area);
|
||||
}
|
||||
}
|
||||
|
||||
ext->btn_pr = new_btn;
|
||||
break;
|
||||
case LV_SIGNAL_RELEASED:
|
||||
case LV_SIGNAL_LONG_PRESS_REP:
|
||||
@ -157,8 +169,18 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
ext->cb(btnm, txt_i);
|
||||
}
|
||||
if(sign == LV_SIGNAL_RELEASED) ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
|
||||
lv_obj_inv(btnm);
|
||||
if(sign == LV_SIGNAL_RELEASED && ext->btn_pr != LV_BTNM_BTN_PR_INVALID) {
|
||||
/*Invalidate to old area*/;
|
||||
lv_obj_get_cords(btnm, &btnm_area);
|
||||
area_cpy(&btn_area, &ext->btn_areas[ext->btn_pr]);
|
||||
btn_area.x1 += btnm_area.x1;
|
||||
btn_area.y1 += btnm_area.y1;
|
||||
btn_area.x2 += btnm_area.x1;
|
||||
btn_area.y2 += btnm_area.y1;
|
||||
lv_inv_area(&btn_area);
|
||||
|
||||
ext->btn_pr = LV_BTNM_BTN_PR_INVALID;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -474,5 +496,29 @@ static uint8_t lv_btnm_get_width_unit(const char * btn_str)
|
||||
|
||||
}
|
||||
|
||||
static uint16_t lv_btnm_get_btn_from_point(lv_obj_t * btnm, point_t * p)
|
||||
{
|
||||
area_t btnm_cords;
|
||||
area_t btn_area;
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
uint16_t i;
|
||||
lv_obj_get_cords(btnm, &btnm_cords);
|
||||
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[i]);
|
||||
btn_area.x1 += btnm_cords.x1;
|
||||
btn_area.y1 += btnm_cords.y1;
|
||||
btn_area.x2 += btnm_cords.x1;
|
||||
btn_area.y2 += btnm_cords.y1;
|
||||
if(area_is_point_on(&btn_area, p) != false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == ext->btn_cnt) i = LV_BTNM_BTN_PR_INVALID;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -35,6 +35,23 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* Type of callback function which is called when a button is released
|
||||
* Parameters: button matrix, released button index in the map string
|
||||
* return LV_ACTION_RES_INV: the button matrix is deleted else LV_ACTION_RES_OK*/
|
||||
typedef lv_action_res_t (*lv_btnm_callback_t) (lv_obj_t *, uint16_t);
|
||||
|
||||
/*Data of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
area_t * btn_areas;
|
||||
uint16_t btn_cnt;
|
||||
uint16_t btn_pr;
|
||||
lv_btnm_callback_t cb;
|
||||
}lv_btnm_ext_t;
|
||||
|
||||
/*Style of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
@ -50,35 +67,69 @@ typedef enum
|
||||
LV_BTNMS_DEF,
|
||||
}lv_btnms_builtin_t;
|
||||
|
||||
/* Type of callback function which is called when a button is released
|
||||
* Parameters: button matrix, released button index in the map string
|
||||
* return LV_ACTION_RES_INV: the button matrix is deleted else LV_ACTION_RES_OK*/
|
||||
typedef lv_action_res_t (*lv_btnm_callback_t) (lv_obj_t *, uint16_t);
|
||||
|
||||
/*Data of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
area_t * btn_areas;
|
||||
uint16_t btn_cnt;
|
||||
uint16_t btn_pr;
|
||||
lv_btnm_callback_t cb;
|
||||
}lv_btnm_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
|
||||
lv_btnms_t * lv_btnms_get(lv_btnms_builtin_t style, lv_btnms_t * copy);
|
||||
|
||||
/**
|
||||
* Create a button matrix objects
|
||||
* @param par pointer to an object, it will be the parent of the new button matrix
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button matrix
|
||||
*/
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a new map. Buttons will be created/deleted according to the map.
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param map pointer a string array. The last string has to be: "".
|
||||
* Use "\n" to begin a new line.
|
||||
* Use octal numbers (e.g. "\003") to set the relative
|
||||
* width of a button. (max. 9 -> \011)
|
||||
* (e.g. const char * str[] = {"a", "b", "\n", "\004c", "d", ""}).
|
||||
* The button do not copy the array so it can not be a local variable.
|
||||
*/
|
||||
void lv_btnm_set_map(lv_obj_t * btnm, const char ** map);
|
||||
|
||||
/**
|
||||
* Set a new callback function for the buttons (It will be called when a button is released)
|
||||
* @param btnm: pointer to button matrix object
|
||||
* @param cb pointer to a callback function
|
||||
*/
|
||||
void lv_btnm_set_cb(lv_obj_t * btnm, lv_btnm_callback_t cb);
|
||||
|
||||
/**
|
||||
* Get the current map of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @return the current map
|
||||
*/
|
||||
const char ** lv_btnm_get_map(lv_obj_t * btnm);
|
||||
|
||||
/**
|
||||
* Get a the callback function of the buttons on a button matrix
|
||||
* @param btnm: pointer to button matrix object
|
||||
* @return pointer to the callback function
|
||||
*/
|
||||
lv_btnm_callback_t lv_btnm_get_cb(lv_obj_t * btnm);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_btnms_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_btnms_t style
|
||||
*/
|
||||
lv_btnms_t * lv_btnms_get(lv_btnms_builtin_t style, lv_btnms_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -32,6 +32,15 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of check box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_btn_ext_t bg_btn; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * bullet;
|
||||
lv_obj_t * label;
|
||||
}lv_cb_ext_t;
|
||||
|
||||
/*Style of check box*/
|
||||
typedef struct
|
||||
{
|
||||
@ -48,22 +57,46 @@ typedef enum
|
||||
LV_CBS_DEF,
|
||||
}lv_cbs_builtin_t;
|
||||
|
||||
/*Data of check box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_btn_ext_t bg_btn; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * bullet;
|
||||
lv_obj_t * label;
|
||||
}lv_cb_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a check box objects
|
||||
* @param par pointer to an object, it will be the parent of the new check box
|
||||
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created check box
|
||||
*/
|
||||
lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the check box
|
||||
* @param cb pointer to a check box object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the text of a check box
|
||||
* @param cb pointer to a check box
|
||||
* @param txt the text of the check box
|
||||
*/
|
||||
void lv_cb_set_text(lv_obj_t * cb, const char * txt);
|
||||
|
||||
/**
|
||||
* Get the text of a check box
|
||||
* @param cb pointer to check box object
|
||||
* @return pointer to the text of the check box
|
||||
*/
|
||||
const char * lv_cb_get_text(lv_obj_t * cb);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_cbs_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_cbs_t style
|
||||
*/
|
||||
lv_cbs_t * lv_cbs_get(lv_cbs_builtin_t style, lv_cbs_t * copy);
|
||||
|
||||
/**********************
|
||||
|
@ -268,6 +268,30 @@ void lv_chart_set_next(lv_obj_t * chart, cord_t * dl, cord_t y)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
* @param chart pointer to chart object
|
||||
* @return type of the chart (from 'lv_chart_t' enum)
|
||||
*/
|
||||
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
return ext->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data point number per data line on chart
|
||||
* @param chart pointer to chart object
|
||||
* @return point number on each data line
|
||||
*/
|
||||
uint16_t lv_chart_get_pnum(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
return ext->pnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_charts_builtin_t enum
|
||||
@ -305,30 +329,6 @@ lv_charts_t * lv_charts_get(lv_charts_builtin_t style, lv_charts_t * copy)
|
||||
return style_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
* @param chart pointer to chart object
|
||||
* @return type of the chart (from 'lv_chart_t' enum)
|
||||
*/
|
||||
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
return ext->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data point number per data line on chart
|
||||
* @param chart pointer to chart object
|
||||
* @return point number on each data line
|
||||
*/
|
||||
uint16_t lv_chart_get_pnum(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
return ext->pnum;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -33,7 +33,22 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of chart background*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg_rects; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
cord_t ymin;
|
||||
cord_t ymax;
|
||||
uint8_t hdiv_num; /*Number of horizontal division lines*/
|
||||
uint8_t vdiv_num; /*Number of vertical division lines*/
|
||||
ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores cord_t * )*/
|
||||
uint16_t pnum; /*Point number in a data line*/
|
||||
uint8_t type :2; /*Line, column or point chart (from 'lv_chart_type_t')*/
|
||||
uint8_t dl_num; /*Data line number in dl_ll*/
|
||||
}lv_chart_ext_t;
|
||||
|
||||
/*Chart types*/
|
||||
typedef enum
|
||||
{
|
||||
LV_CHART_LINE,
|
||||
@ -61,41 +76,101 @@ typedef enum
|
||||
LV_CHARTS_TRANSP,
|
||||
}lv_charts_builtin_t;
|
||||
|
||||
/*Data of chart background*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg_rects; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
cord_t ymin;
|
||||
cord_t ymax;
|
||||
uint8_t hdiv_num;
|
||||
uint8_t vdiv_num;
|
||||
ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores cord_t * )*/
|
||||
uint16_t pnum; /*Point number in a data line*/
|
||||
uint8_t type :2; /*Line, column or point chart*/
|
||||
uint8_t dl_num; /*Data line number in dl_ll*/
|
||||
}lv_chart_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
|
||||
lv_charts_t * lv_charts_get(lv_charts_builtin_t style, lv_charts_t * copy);
|
||||
|
||||
/**
|
||||
* Create a chart background objects
|
||||
* @param par pointer to an object, it will be the parent of the new chart background
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created chart background
|
||||
*/
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the chart background
|
||||
* @param chart pointer to a chart background object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Allocate and add a data line to the chart
|
||||
* @param chart pointer to a chart object
|
||||
* @return pointer to the allocated data lie (an array for the data points)
|
||||
*/
|
||||
cord_t * lv_chart_add_dataline(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Refresh a chart if its data line has changed
|
||||
* @param chart pointer to chart object
|
||||
*/
|
||||
void lv_chart_refr(lv_obj_t * chart);
|
||||
|
||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
|
||||
/**
|
||||
* Set the number of horizontal and vertical division lines
|
||||
* @param chart pointer to a graph background object
|
||||
* @param hdiv number of horizontal division lines
|
||||
* @param vdiv number of vertical division lines
|
||||
*/
|
||||
void lv_chart_set_hvdiv(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
|
||||
|
||||
/**
|
||||
* Set the minimal and maximal x and y values
|
||||
* @param chart pointer to a graph background object
|
||||
* @param xmin x minimum value
|
||||
* @param xmax x maximum value
|
||||
* @param ymin y minimum value
|
||||
* @param ymax y maximum value
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, cord_t ymin, cord_t ymax);
|
||||
|
||||
/**
|
||||
* Set a new type for a chart
|
||||
* @param chart pointer to a chart object
|
||||
* @param type new type of the chart (from 'lv_chart_type_t' enum)
|
||||
*/
|
||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
|
||||
|
||||
/**
|
||||
* Set the number of points on a data line on a chart
|
||||
* @param chart pointer r to chart object
|
||||
* @param pnum new number of points on the data lines
|
||||
*/
|
||||
void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum);
|
||||
|
||||
/**
|
||||
* Shift all data right and set the most right data on a data line
|
||||
* @param chart pointer to chart object
|
||||
* @param dl pointer to a data line on 'chart'
|
||||
* @param y the new value of the most right data
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, cord_t * dl, cord_t y);
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
* @param chart pointer to chart object
|
||||
* @return type of the chart (from 'lv_chart_t' enum)
|
||||
*/
|
||||
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Get the data point number per data line on chart
|
||||
* @param chart pointer to chart object
|
||||
* @return point number on each data line
|
||||
*/
|
||||
uint16_t lv_chart_get_pnum(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_charts_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_charts_t style
|
||||
*/
|
||||
lv_charts_t * lv_charts_get(lv_charts_builtin_t style, lv_charts_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
552
lv_objx/lv_gauge.c
Normal file
552
lv_objx/lv_gauge.c
Normal file
@ -0,0 +1,552 @@
|
||||
/**
|
||||
* @file lv_gauge.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_GAUGE != 0
|
||||
|
||||
#include "lv_gauge.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/text.h"
|
||||
#include "misc/math/trigo.h"
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_GAUGE_DEF_WIDTH (150 * LV_DOWNSCALE)
|
||||
#define LV_GAUGE_DEF_HEIGHT (150 * LV_DOWNSCALE)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask);
|
||||
static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask);
|
||||
static void lv_gauges_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_gauges_t lv_gauges_def; /*Default gauge style*/
|
||||
static lv_design_f_t ancestor_design_f = NULL;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a gauge objects
|
||||
* @param par pointer to an object, it will be the parent of the new gauge
|
||||
* @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created gauge
|
||||
*/
|
||||
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor gauge*/
|
||||
lv_obj_t * new_gauge = lv_rect_create(par, copy);
|
||||
dm_assert(new_gauge);
|
||||
|
||||
/*Allocate the gauge type specific extended data*/
|
||||
lv_gauge_ext_t * ext = lv_obj_alloc_ext(new_gauge, sizeof(lv_gauge_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->min = 0;
|
||||
ext->max = 100;
|
||||
ext->needle_num = 1;
|
||||
ext->low_critical = 0;
|
||||
ext->values = NULL;
|
||||
ext->txt = NULL;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_gauge);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_f(new_gauge, lv_gauge_design);
|
||||
|
||||
/*Init the new gauge gauge*/
|
||||
if(copy == NULL) {
|
||||
lv_gauge_set_needle_num(new_gauge, 1);
|
||||
lv_gauge_set_text(new_gauge, "%d");
|
||||
lv_obj_set_size(new_gauge, LV_GAUGE_DEF_WIDTH, LV_GAUGE_DEF_HEIGHT);
|
||||
lv_obj_set_style(new_gauge, lv_gauges_get(LV_GAUGES_DEF, NULL));
|
||||
}
|
||||
/*Copy an existing gauge*/
|
||||
else {
|
||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->min = copy_ext->min;
|
||||
ext->max = copy_ext->max;
|
||||
ext->low_critical = copy_ext->low_critical;
|
||||
lv_gauge_set_needle_num(new_gauge, lv_gauge_get_needle_num(copy));
|
||||
lv_gauge_set_text(new_gauge, lv_gauge_get_text(copy));
|
||||
|
||||
uint8_t i;
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
ext->values[i] = copy_ext->values[i];
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_gauge);
|
||||
}
|
||||
|
||||
return new_gauge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(gauge, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
dm_free(ext->values);
|
||||
ext->values = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the number of needles (should be <= LV_GAUGE_MAX_NEEDLE)
|
||||
* @param gauge pointer to gauge object
|
||||
* @param num number of needles
|
||||
*/
|
||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
if(ext->values != NULL) dm_free(ext->values);
|
||||
|
||||
ext->values = dm_alloc(num * sizeof(int16_t));
|
||||
|
||||
ext->needle_num = num;
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the range of a gauge
|
||||
* @param gauge pointer to gauge object
|
||||
* @param min min value
|
||||
* @param max max value
|
||||
*/
|
||||
void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
/*Be sure the smaller value is min and the greater is max*/
|
||||
ext->min = MATH_MIN(min, max);
|
||||
ext->max = MATH_MAX(min, max);
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a needle
|
||||
* @param gauge pointer to gauge
|
||||
* @param needle the id of the needle
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
if(needle >= ext->needle_num) return;
|
||||
|
||||
if(value > ext->max) value = ext->max;
|
||||
if(value < ext->min) value = ext->min;
|
||||
|
||||
ext->values[needle] = value;
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text on a gauge
|
||||
* @param gauge pinter to a gauge object
|
||||
* @param txt a printf like format string
|
||||
* with 1 place for a number (e.g. "Value: %d");
|
||||
*/
|
||||
void lv_gauge_set_text(lv_obj_t * gauge, const char * txt)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
if(ext->txt != NULL) dm_free(ext->txt);
|
||||
|
||||
ext->txt = dm_alloc(strlen(txt) + 1);
|
||||
strcpy(ext->txt, txt);
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
ext->low_critical = low == false ? 0 : 1;
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the number of needles on a gauge
|
||||
* @param gauge pointer to gauge
|
||||
* @return number of needles
|
||||
*/
|
||||
uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
return ext->needle_num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a needle
|
||||
* @param gauge pointer to gauge object
|
||||
* @param needle the id of the needle
|
||||
* @return the value of the needle [min,max]
|
||||
*/
|
||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
if(needle >= ext->needle_num) return ext->min;
|
||||
|
||||
return ext->values[needle];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text of a gauge
|
||||
* @param gauge pointer to gauge
|
||||
* @return the set text. (not with the current value)
|
||||
*/
|
||||
const char * lv_gauge_get_text(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
return ext->txt;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
bool lv_gauge_get_low_critical(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
return ext->low_critical == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_gauges_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_gauges_t style
|
||||
*/
|
||||
lv_gauges_t * lv_gauges_get(lv_gauges_builtin_t style, lv_gauges_t * copy)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_gauges_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_gauges_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
case LV_GAUGES_DEF:
|
||||
style_p = &lv_gauges_def;
|
||||
break;
|
||||
default:
|
||||
style_p = &lv_gauges_def;
|
||||
}
|
||||
|
||||
if(copy != NULL) {
|
||||
if(style_p != NULL) memcpy(copy, style_p, sizeof(lv_gauges_t));
|
||||
else memcpy(copy, &lv_gauges_def, sizeof(lv_gauges_t));
|
||||
}
|
||||
|
||||
return style_p;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the gauges
|
||||
* @param gauge pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design_f(gauge, mask, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_gauges_t * style = lv_obj_get_style(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
/* Draw the background
|
||||
* Re-color the gauge according to the critical value*/
|
||||
color_t mcolor_min = style->rects.objs.color;
|
||||
color_t gcolor_min = style->rects.gcolor;
|
||||
|
||||
int16_t critical_val = ext->low_critical == 0 ? ext->min : ext->max;
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
critical_val = ext->low_critical == 0 ? MATH_MAX(critical_val, ext->values[i]) : MATH_MIN(critical_val, ext->values[i]);
|
||||
}
|
||||
|
||||
opa_t ratio = ((critical_val - ext->min) * OPA_COVER) / (ext->max - ext->min);
|
||||
|
||||
if(ext->low_critical != 0) ratio = OPA_COVER - ratio;
|
||||
|
||||
style->rects.objs.color= color_mix(style->mcolor_critical, mcolor_min, ratio);
|
||||
style->rects.gcolor = color_mix(style->gcolor_critical, gcolor_min, ratio);
|
||||
ancestor_design_f(gauge, mask, mode);
|
||||
style->rects.objs.color= mcolor_min;
|
||||
style->rects.gcolor = gcolor_min;
|
||||
|
||||
lv_gauge_draw_scale(gauge, mask);
|
||||
|
||||
lv_gauge_draw_needle(gauge, mask);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
ancestor_design_f(gauge, mask, mode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the scale on a gauge
|
||||
* @param gauge pointer to gauge object
|
||||
* @param mask mask of drawing
|
||||
*/
|
||||
static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask)
|
||||
{
|
||||
lv_gauges_t * style = lv_obj_get_style(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
char scale_txt[16];
|
||||
|
||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->scale_pad;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||
int16_t angle_ofs = 90 + (360 - style->scale_angle) / 2;
|
||||
|
||||
uint8_t i;
|
||||
for(i = 0; i < style->scale_label_num; i++) {
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * style->scale_angle) / (style->scale_label_num - 1) + angle_ofs;
|
||||
|
||||
cord_t y = (int32_t)((int32_t)trigo_sin(angle) * r) / TRIGO_SIN_MAX;
|
||||
y += y_ofs;
|
||||
|
||||
cord_t x = (int32_t)((int32_t)trigo_sin(angle + 90) * r) / TRIGO_SIN_MAX;
|
||||
x += x_ofs;
|
||||
|
||||
int16_t scale_act = (int32_t)((int32_t)(ext->max - ext->min) * i) / (style->scale_label_num - 1);
|
||||
scale_act += ext->min;
|
||||
sprintf(scale_txt, "%d", scale_act);
|
||||
|
||||
area_t label_cord;
|
||||
point_t label_size;
|
||||
txt_get_size(&label_size, scale_txt, font_get(style->scale_labels.font),
|
||||
style->scale_labels.letter_space, style->scale_labels.line_space, LV_CORD_MAX);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = x - label_size.x / 2;
|
||||
label_cord.y1 = y - label_size.y / 2;
|
||||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, mask, &style->scale_labels, OPA_COVER, scale_txt);
|
||||
}
|
||||
|
||||
/*Calculate the critical value*/
|
||||
int16_t critical_value = ext->low_critical == 0 ? ext->min : ext->max;;
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
critical_value = ext->low_critical == 0 ?
|
||||
MATH_MAX(critical_value, ext->values[i]) : MATH_MIN(critical_value, ext->values[i]);
|
||||
}
|
||||
|
||||
/*Write the critical value if enabled*/
|
||||
if(ext->txt[0] != '\0') {
|
||||
char value_txt[16];
|
||||
sprintf(value_txt, ext->txt, critical_value);
|
||||
|
||||
area_t label_cord;
|
||||
point_t label_size;
|
||||
txt_get_size(&label_size, value_txt, font_get(style->value_labels.font),
|
||||
style->value_labels.letter_space, style->value_labels.line_space, LV_CORD_MAX);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = gauge->cords.x1 + lv_obj_get_width(gauge) / 2 - label_size.x / 2;
|
||||
label_cord.y1 = gauge->cords.y1 +
|
||||
(cord_t)style->value_pos * lv_obj_get_height(gauge) / 100 - label_size.y / 2;
|
||||
|
||||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, mask, &style->value_labels, OPA_COVER, value_txt);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Draw the needles of a gauge
|
||||
* @param gauge pointer to gauge object
|
||||
* @param mask mask of drawing
|
||||
*/
|
||||
static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask)
|
||||
{
|
||||
lv_gauges_t * style = lv_obj_get_style(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->scale_pad;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||
int16_t angle_ofs = 90 + (360 - style->scale_angle) / 2;
|
||||
point_t p_mid;
|
||||
point_t p_end;
|
||||
uint8_t i;
|
||||
|
||||
p_mid.x = x_ofs;
|
||||
p_mid.y = y_ofs;
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
/*Calculate the end point of a needle*/
|
||||
int16_t needle_angle = (ext->values[i] - ext->min) * style->scale_angle /
|
||||
(ext->max - ext->min) + angle_ofs;
|
||||
p_end.y = (trigo_sin(needle_angle) * r) / TRIGO_SIN_MAX + y_ofs;
|
||||
p_end.x = (trigo_sin(needle_angle + 90) * r) / TRIGO_SIN_MAX + x_ofs;
|
||||
|
||||
/*Draw the needle with the corresponding color*/
|
||||
style->needle_lines.objs.color = style->needle_color[i];
|
||||
|
||||
lv_draw_line(&p_mid, &p_end, mask, &style->needle_lines, style->needle_opa);
|
||||
|
||||
}
|
||||
|
||||
/*Draw the needle middle area*/
|
||||
lv_rects_t nm;
|
||||
area_t nm_cord;
|
||||
lv_rects_get(LV_RECTS_DEF, &nm);
|
||||
nm.bwidth = 0;
|
||||
nm.round = LV_RECT_CIRCLE;
|
||||
nm.objs.color = style->needle_mid_color;
|
||||
nm.gcolor = style->needle_mid_color;
|
||||
|
||||
nm_cord.x1 = x_ofs - style->needle_mid_r;
|
||||
nm_cord.y1 = y_ofs - style->needle_mid_r;
|
||||
nm_cord.x2 = x_ofs + style->needle_mid_r;
|
||||
nm_cord.y2 = y_ofs + style->needle_mid_r;
|
||||
|
||||
lv_draw_rect(&nm_cord, mask, &nm, OPA_100);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the built-in gauge styles
|
||||
*/
|
||||
static void lv_gauges_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_gauges_def.rects);
|
||||
lv_gauges_def.rects.round = LV_RECT_CIRCLE;
|
||||
lv_gauges_def.rects.bwidth = 4 * LV_DOWNSCALE;
|
||||
lv_gauges_def.rects.objs.color = COLOR_MAKE(0x00, 0xaa, 0x00);//GREEN;
|
||||
lv_gauges_def.rects.gcolor = COLOR_BLACK;
|
||||
lv_gauges_def.rects.bcolor = COLOR_BLACK;
|
||||
|
||||
lv_gauges_def.gcolor_critical = COLOR_BLACK;
|
||||
lv_gauges_def.mcolor_critical = COLOR_MAKE(0xff, 0x50, 0x50);
|
||||
|
||||
lv_labels_get(LV_LABELS_DEF, &lv_gauges_def.scale_labels);
|
||||
lv_gauges_def.scale_labels.objs.color = COLOR_MAKE(0xd0, 0xd0, 0xd0);
|
||||
|
||||
lv_labels_get(LV_LABELS_DEF, &lv_gauges_def.value_labels);
|
||||
lv_gauges_def.value_labels.objs.color = COLOR_WHITE;
|
||||
lv_gauges_def.value_labels.letter_space = 3 * LV_DOWNSCALE;
|
||||
lv_gauges_def.value_labels.mid = 1;
|
||||
|
||||
lv_gauges_def.value_pos = 75;
|
||||
|
||||
lv_lines_get(LV_LINES_DEF, &lv_gauges_def.needle_lines);
|
||||
lv_gauges_def.needle_lines.objs.color = COLOR_WHITE;
|
||||
lv_gauges_def.needle_lines.width = 3 * LV_DOWNSCALE;
|
||||
|
||||
lv_gauges_def.needle_color[0] = COLOR_SILVER;
|
||||
lv_gauges_def.needle_color[1] = COLOR_MAKE(0x40, 0x90, 0xe0);
|
||||
lv_gauges_def.needle_color[2] = COLOR_MAKE(0x50, 0xe0, 0x50);
|
||||
lv_gauges_def.needle_color[3] = COLOR_MAKE(0xff, 0xff, 0x70);
|
||||
|
||||
lv_gauges_def.needle_mid_r = 5 * LV_DOWNSCALE;
|
||||
lv_gauges_def.needle_mid_color = COLOR_GRAY;
|
||||
lv_gauges_def.needle_opa = OPA_80;
|
||||
lv_gauges_def.scale_pad = 20 * LV_DOWNSCALE;
|
||||
lv_gauges_def.scale_label_num = 6;
|
||||
lv_gauges_def.scale_angle = 220;
|
||||
}
|
||||
|
||||
#endif
|
193
lv_objx/lv_gauge.h
Normal file
193
lv_objx/lv_gauge.h
Normal file
@ -0,0 +1,193 @@
|
||||
/**
|
||||
* @file lv_gauge.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GAUGE_H
|
||||
#define LV_GAUGE_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "misc_conf.h"
|
||||
#if USE_LV_GAUGE != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_RECT == 0
|
||||
#error "lv_gauge: lv_rect is required. Enable it in lv_conf.h (USE_LV_RECT 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_gauge: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_RECT == 0
|
||||
#error "lv_gauge: lv_line is required. Enable it in lv_conf.h (USE_LV_LINE 1) "
|
||||
#endif
|
||||
|
||||
#if USE_TRIGO == 0
|
||||
#error "lv_gauge: trigo is required. Enable it in misc_conf.h (USE_TRIGO 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include "lv_label.h"
|
||||
#include "lv_line.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_GAUGE_MAX_NEEDLE 4 /*Max number of needles. Used in the style.*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of gauge*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
int16_t min; /*Minimum value of the scale*/
|
||||
int16_t max; /*Maximum value of the scale*/
|
||||
int16_t * values; /*Array of the set values (for needles) */
|
||||
char * txt; /*Printf-like text to display with the most critical value (e.g. "Value: %d")*/
|
||||
uint8_t needle_num; /*Number of needles*/
|
||||
uint8_t low_critical :1; /*0: the higher value is more critical, 1: the lower value is more critical*/
|
||||
}lv_gauge_ext_t;
|
||||
|
||||
/*Style of gauge*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t rects; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
color_t mcolor_critical; /*Top color at critical.*/
|
||||
color_t gcolor_critical; /*Bottom color at critical*/
|
||||
/*Scale settings*/
|
||||
uint16_t scale_angle; /*Angle of the scale in deg. (~220)*/
|
||||
lv_labels_t scale_labels; /*Style of the scale labels*/
|
||||
cord_t scale_pad; /*Padding of scale labels from the edge*/
|
||||
uint8_t scale_label_num; /*Number of scale labels (~6)*/
|
||||
/*Needle settings*/
|
||||
lv_lines_t needle_lines; /*Style of neddles*/
|
||||
color_t needle_color[LV_GAUGE_MAX_NEEDLE]; /*Color of needles*/
|
||||
color_t needle_mid_color; /*Color of middle where the needles start*/
|
||||
cord_t needle_mid_r; /*Radius of the needle middle area*/
|
||||
opa_t needle_opa; /*Opacity of the needles*/
|
||||
/*Value text settings*/
|
||||
lv_labels_t value_labels; /*Style of the value label*/
|
||||
uint8_t value_pos; /*Vertical position of the value label in percentage of object height (0..100 %)*/
|
||||
}lv_gauges_t;
|
||||
|
||||
/*Built-in styles of gauge*/
|
||||
typedef enum
|
||||
{
|
||||
LV_GAUGES_DEF,
|
||||
}lv_gauges_builtin_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Create a gauge objects
|
||||
* @param par pointer to an object, it will be the parent of the new gauge
|
||||
* @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created gauge
|
||||
*/
|
||||
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the number of needles (should be <= LV_GAUGE_MAX_NEEDLE)
|
||||
* @param gauge pointer to gauge object
|
||||
* @param num number of needles
|
||||
*/
|
||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num);
|
||||
|
||||
/**
|
||||
* Set the range of a gauge
|
||||
* @param gauge pointer to gauge object
|
||||
* @param min min value
|
||||
* @param max max value
|
||||
*/
|
||||
void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max);
|
||||
|
||||
/**
|
||||
* Set the value of a needle
|
||||
* @param gauge pointer to gauge
|
||||
* @param needle the id of the needle
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value);
|
||||
|
||||
/**
|
||||
* Set text on a gauge
|
||||
* @param gauge pinter to a gauge object
|
||||
* @param txt a printf like format string
|
||||
* with 1 place for a number (e.g. "Value: %d");
|
||||
*/
|
||||
void lv_gauge_set_text(lv_obj_t * gauge, const char * txt);
|
||||
|
||||
/**
|
||||
* Set which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low);
|
||||
|
||||
/**
|
||||
* Get the number of needles on a gauge
|
||||
* @param gauge pointer to gauge
|
||||
* @return number of needles
|
||||
*/
|
||||
uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge);
|
||||
|
||||
/**
|
||||
* Get the value of a needle
|
||||
* @param gauge pointer to gauge object
|
||||
* @param needle the id of the needle
|
||||
* @return the value of the needle [min,max]
|
||||
*/
|
||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle);
|
||||
|
||||
/**
|
||||
* Get the text of a gauge
|
||||
* @param gauge pointer to gauge
|
||||
* @return the set text. (not with the current value)
|
||||
*/
|
||||
const char * lv_gauge_get_text(lv_obj_t * gauge);
|
||||
|
||||
/**
|
||||
* Get which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
bool lv_gauge_get_low_critical(lv_obj_t * gauge);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_gauges_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_gauges_t style
|
||||
*/
|
||||
lv_gauges_t * lv_gauges_get(lv_gauges_builtin_t style, lv_gauges_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
159
lv_objx/lv_img.c
159
lv_objx/lv_img.c
@ -15,6 +15,10 @@
|
||||
#include "misc/fs/fsint.h"
|
||||
#include "misc/fs/ufs/ufs.h"
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#include "../lv_misc/text.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -29,6 +33,8 @@
|
||||
static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_imgs_init(void);
|
||||
|
||||
static bool lv_img_is_symbol(const char * txt);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -65,6 +71,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->w = lv_obj_get_width(new_img);
|
||||
ext->h = lv_obj_get_height(new_img);
|
||||
ext->transp = 0;
|
||||
ext->upscale = 0;
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_f(new_img, lv_img_signal);
|
||||
@ -185,28 +192,58 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
fs_file_t file;
|
||||
fs_res_t res;
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t rn;
|
||||
|
||||
res = fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
res = fs_read(&file, &header, sizeof(header), &rn);
|
||||
}
|
||||
/*Handle normal images*/
|
||||
if(lv_img_is_symbol(fn) == false) {
|
||||
|
||||
fs_file_t file;
|
||||
fs_res_t res;
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t rn;
|
||||
res = fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
res = fs_read(&file, &header, sizeof(header), &rn);
|
||||
}
|
||||
|
||||
/*Create a dummy header on fs error*/
|
||||
if(res != FS_RES_OK || rn != sizeof(header)) {
|
||||
header.w = lv_obj_get_width(img);
|
||||
header.h = lv_obj_get_height(img);
|
||||
header.transp = 0;
|
||||
}
|
||||
|
||||
fs_close(&file);
|
||||
|
||||
ext->w = header.w;
|
||||
ext->h = header.h;
|
||||
ext->transp = header.transp;
|
||||
|
||||
if(ext->upscale != 0) {
|
||||
ext->w *= 2;
|
||||
ext->h *= 2;
|
||||
}
|
||||
}
|
||||
/*Handle symbol texts*/
|
||||
else {
|
||||
#if LV_IMG_ENABLE_SYMBOLS
|
||||
lv_imgs_t * imgs = lv_obj_get_style(img);
|
||||
point_t size;
|
||||
txt_get_size(&size, fn, font_get(imgs->sym_font), 0, 0, LV_CORD_MAX);
|
||||
ext->w = size.x;
|
||||
ext->h = size.y;
|
||||
ext->transp = 0;
|
||||
#else
|
||||
/*Never goes here, just to be sure handle this */
|
||||
ext->w = lv_obj_get_width(img);
|
||||
ext->h = lv_obj_get_height(img);
|
||||
ext->transp = 0;
|
||||
#endif
|
||||
|
||||
if(res != FS_RES_OK || rn != sizeof(header)) {
|
||||
/*Create a dummy header*/
|
||||
header.w = lv_obj_get_width(img);
|
||||
header.h = lv_obj_get_height(img);
|
||||
header.transp = 0;
|
||||
}
|
||||
|
||||
fs_close(&file);
|
||||
|
||||
ext->w = header.w;
|
||||
ext->h = header.h;
|
||||
ext->transp = header.transp;
|
||||
if(ext->upscale != 0) {
|
||||
ext->w *= LV_DOWNSCALE;
|
||||
ext->h *= LV_DOWNSCALE;
|
||||
}
|
||||
|
||||
if(fn != NULL) {
|
||||
ext->fn = dm_realloc(ext->fn, strlen(fn) + 1);
|
||||
@ -215,8 +252,9 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
ext->fn = NULL;
|
||||
}
|
||||
|
||||
|
||||
if(lv_img_get_auto_size(img) != false) {
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
|
||||
lv_obj_inv(img);
|
||||
@ -226,13 +264,30 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
* Enable the auto size feature.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
* @param img pointer to an image
|
||||
* @param autotosize true: auto size enable, false: auto size disable
|
||||
* @param en true: auto size enable, false: auto size disable
|
||||
*/
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool autotosize)
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
ext->auto_size = (autotosize == false ? 0 : 1);
|
||||
ext->auto_size = (en == false ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable the upscaling with LV_DOWNSCALE.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
* @param img pointer to an image
|
||||
* @param en true: upscale enable, false: upscale disable
|
||||
*/
|
||||
void lv_img_set_upscale(lv_obj_t * img, bool en)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
ext->upscale = (en == false ? 0 : 1);
|
||||
|
||||
/*Refresh the image with the new size*/
|
||||
lv_img_set_file(img, ext->fn);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -251,6 +306,17 @@ bool lv_img_get_auto_size(lv_obj_t * img)
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upscale enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: upscale is enabled, false: upscale is disabled
|
||||
*/
|
||||
bool lv_img_get_upscale(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
return ext->upscale == 0 ? false : true;
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -278,7 +344,19 @@ static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t
|
||||
}
|
||||
else return false;
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
if(ext->h == 0 || ext->w == 0) return true;
|
||||
area_t cords;
|
||||
/*Create a default style for symbol texts*/
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
bool sym = lv_img_is_symbol(ext->fn);
|
||||
lv_labels_t sym_style;
|
||||
lv_labels_get(LV_LABELS_DEF, &sym_style);
|
||||
sym_style.font = imgs_p->sym_font;
|
||||
sym_style.letter_space = 0;
|
||||
sym_style.line_space = 0;
|
||||
sym_style.mid = 0;
|
||||
sym_style.objs.color = imgs_p->objs.color;
|
||||
#endif
|
||||
|
||||
lv_obj_get_cords(img, &cords);
|
||||
opa_t opa = lv_obj_get_opa(img);
|
||||
@ -291,13 +369,42 @@ static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t
|
||||
cords_tmp.x1 = cords.x1;
|
||||
cords_tmp.x2 = cords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
lv_draw_img(&cords_tmp, mask, imgs_p, opa, ext->fn);
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS == 0
|
||||
lv_draw_img(&cords_tmp, mask, imgs_p, opa, ext->fn);
|
||||
#else
|
||||
if(sym == false) lv_draw_img(&cords_tmp, mask, imgs_p, opa, ext->fn);
|
||||
else lv_draw_label(&cords_tmp, mask, &sym_style, opa, ext->fn);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* From the settings in lv_conf.h and the file name
|
||||
* tells it a filename or a symbol text.
|
||||
* @param txt a file name (e.g. "U:/file1") or a symbol (e.g. SYMBOL_OK)
|
||||
* @return true: 'txt' is a symbol text, false: 'txt' is a file name
|
||||
*/
|
||||
static bool lv_img_is_symbol(const char * txt)
|
||||
{
|
||||
/*If the symbols are not enabled always tell false*/
|
||||
#if LV_IMG_ENABLE_SYMBOLS == 0
|
||||
return false;
|
||||
#endif
|
||||
|
||||
/* if txt begins with an upper case letter then it refers to a driver
|
||||
* so it is a file name*/
|
||||
if(txt[0] >= 'A' && txt[0] <= 'Z') return false;
|
||||
|
||||
/*If not returned during the above tests then it is symbol text*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the image styles
|
||||
*/
|
||||
@ -306,7 +413,9 @@ static void lv_imgs_init(void)
|
||||
/*Default style*/
|
||||
lv_imgs_def.objs.color = COLOR_BLACK;
|
||||
lv_imgs_def.recolor_opa = OPA_TRANSP;
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
lv_imgs_def.sym_font = LV_IMG_DEF_SYMBOL_FONT;
|
||||
#endif
|
||||
/*Dark style*/
|
||||
memcpy(&lv_imgs_dark, &lv_imgs_def, sizeof(lv_imgs_t));
|
||||
lv_imgs_dark.objs.color = COLOR_BLACK; lv_imgs_dark.recolor_opa = OPA_50;
|
||||
|
129
lv_objx/lv_img.h
129
lv_objx/lv_img.h
@ -13,9 +13,22 @@
|
||||
#include "misc_conf.h"
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0
|
||||
|
||||
#if USE_FSINT == 0
|
||||
#error "lv_img: fsint is required. Enable it in misc_conf.h (USE_FSINT 1) "
|
||||
#endif
|
||||
|
||||
#if USE_UFS == 0
|
||||
#error "lv_img: ufs is required. Enable it in misc_conf.h (USE_UFS 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "misc/fs/fsint.h"
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS
|
||||
#include "lv_label.h"
|
||||
#include "../lv_misc/fonts/symbol_def.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -23,16 +36,31 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of image*/
|
||||
typedef struct
|
||||
{
|
||||
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
||||
cord_t w; /*Width of the image (doubled when upscaled)*/
|
||||
cord_t h; /*Height of the image (doubled when upscaled)*/
|
||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||
uint8_t upscale :1; /*1: upscale to double size*/
|
||||
uint8_t transp :1; /*Transp. bit in the image header (library handles this)*/
|
||||
}lv_img_ext_t;
|
||||
|
||||
/*Style of template*/
|
||||
/*Style of image*/
|
||||
typedef struct
|
||||
{
|
||||
lv_objs_t objs; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
opa_t recolor_opa;
|
||||
opa_t recolor_opa; /*Intensity of recoloring (OPA_TRANSP, OPA_10 ... OPA_COVER)*/
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
font_types_t sym_font; /*Symbol font*/
|
||||
#endif
|
||||
}lv_imgs_t;
|
||||
|
||||
/*Built-in styles of template*/
|
||||
/*Built-in styles of image*/
|
||||
typedef enum
|
||||
{
|
||||
LV_IMGS_DEF,
|
||||
@ -40,46 +68,101 @@ typedef enum
|
||||
LV_IMGS_DARK,
|
||||
}lv_imgs_builtin_t;
|
||||
|
||||
/*Data of template*/
|
||||
typedef struct
|
||||
{
|
||||
/*No ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
||||
cord_t w; /*Width of the image (if LV_UPSCALE_MAP != 0 then multiplied by LV_DOWNSCALE)*/
|
||||
cord_t h; /*Height of the image (if LV_UPSCALE_MAP != 0 then multiplied by LV_DOWNSCALE)*/
|
||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||
uint8_t transp :1; /*Transp. bit in the images header (library handles this)*/
|
||||
}lv_img_ext_t;
|
||||
|
||||
/*Image header*/
|
||||
/* Image header it is compatible with
|
||||
* the result image converter utility*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t w; /*Width of the image map*/
|
||||
uint16_t h; /*Height of the image map*/
|
||||
uint16_t cd; /*Color depth (8/16 or 24)*/
|
||||
uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/
|
||||
uint16_t w; /*Width of the image map*/
|
||||
uint16_t h; /*Height of the image map*/
|
||||
uint16_t cd; /*Color depth (8/16 or 24)*/
|
||||
uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/
|
||||
}lv_img_raw_header_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
/*Create function*/
|
||||
|
||||
|
||||
/**
|
||||
* Create an image objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a rectangle object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created image
|
||||
*/
|
||||
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the image
|
||||
* @param img pointer to animage object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param);
|
||||
void lv_img_set_file(lv_obj_t * img, const char * fn);
|
||||
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data_p);
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool autotosize);
|
||||
|
||||
/**
|
||||
* Return with a pointer to built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_imgs_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_imgs_t style
|
||||
*/
|
||||
lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy);
|
||||
|
||||
/**
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data);
|
||||
|
||||
/**
|
||||
* Set a file to the image
|
||||
* @param img pointer to an image object
|
||||
* @param fn file name in the RAMFS to set as picture (e.g. "U:/pic1").
|
||||
*/
|
||||
void lv_img_set_file(lv_obj_t * img, const char * fn);
|
||||
|
||||
/**
|
||||
* Enable the auto size feature.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
* @param img pointer to an image
|
||||
* @param en true: auto size enable, false: auto size disable
|
||||
*/
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool en);
|
||||
|
||||
/**
|
||||
* Enable the upscaling with LV_DOWNSCALE.
|
||||
* @param img pointer to an image
|
||||
* @param en true: upscale enable, false: upscale disable
|
||||
*/
|
||||
void lv_img_set_upscale(lv_obj_t * img, bool en);
|
||||
|
||||
/**
|
||||
* Get the auto size enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: auto size is enabled, false: auto size is disabled
|
||||
*/
|
||||
bool lv_img_get_auto_size(lv_obj_t * img);
|
||||
|
||||
|
||||
/**
|
||||
* Get the upscale enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: upscale is enabled, false: upscale is disabled
|
||||
*/
|
||||
bool lv_img_get_upscale(lv_obj_t * img);
|
||||
|
||||
|
||||
lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/*Use this macro to declare an image in a c file*/
|
||||
#define LV_IMG_DECLARE(var_name) extern const color_int_t var_name[];
|
||||
|
||||
#endif
|
||||
|
@ -20,6 +20,23 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_LABEL_SCROLL_SPEED
|
||||
#define LV_LABEL_SCROLL_SPEED (25 * LV_DOWNSCALE) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_SPEED_VER
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 * LV_DOWNSCALE) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_PLAYBACK_PAUSE
|
||||
#define LV_LABEL_SCROLL_PLAYBACK_PAUSE 500 /*Wait before the scroll turns back in ms*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_REPEAT_PAUSE
|
||||
#define LV_LABEL_SCROLL_REPEAT_PAUSE 500 /*Wait before the scroll begins again in ms*/
|
||||
#endif
|
||||
|
||||
#define LV_LABEL_DOT_NUM 3
|
||||
#define LV_LABEL_DOT_END_INV 0xFFFF
|
||||
|
||||
|
@ -24,15 +24,36 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Long mode behaviors. Used in 'lv_label_ext_t' */
|
||||
typedef enum
|
||||
{
|
||||
LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/
|
||||
LV_LABEL_LONG_BREAK, /*Keep the width and break the text and expand the object height*/
|
||||
LV_LABEL_LONG_DOTS, /*Keep the size, break the text and write dots in the last line*/
|
||||
LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text on the parent (move the label object)*/
|
||||
}lv_label_long_mode_t;
|
||||
|
||||
/*Data of label*/
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char * txt; /*Text of the label*/
|
||||
lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/
|
||||
char dot_tmp[LV_LABEL_DOT_NUM]; /*Store character which are replaced with dots*/
|
||||
uint16_t dot_end; /* The text end position in dot mode*/
|
||||
uint8_t static_txt :1; /* Flag to indicate the text is static*/
|
||||
}lv_label_ext_t;
|
||||
|
||||
/*Style of label*/
|
||||
typedef struct
|
||||
{
|
||||
lv_objs_t objs; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
font_types_t font;
|
||||
font_types_t font; /*Name of the font. E.g: FONT_DEJAVU_20*/
|
||||
uint16_t letter_space;
|
||||
uint16_t line_space;
|
||||
uint8_t mid :1;
|
||||
uint8_t mid :1; /*1: Align the lines into the middle*/
|
||||
}lv_labels_t;
|
||||
|
||||
/*Built-in styles of label*/
|
||||
@ -44,44 +65,95 @@ typedef enum
|
||||
LV_LABELS_TITLE,
|
||||
}lv_labels_builtin_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/
|
||||
LV_LABEL_LONG_BREAK, /*Keep the width and break the text and expand the object height*/
|
||||
LV_LABEL_LONG_DOTS, /*Keep the size, break the text and write dots in the last line*/
|
||||
LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text (move the label object)*/
|
||||
}lv_label_long_mode_t;
|
||||
|
||||
/*Data of label*/
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char * txt;
|
||||
lv_label_long_mode_t long_mode;
|
||||
char dot_tmp[LV_LABEL_DOT_NUM]; /*Store character which are replaced with dots*/
|
||||
uint16_t dot_end; /* The text end in dot mode*/
|
||||
uint8_t static_txt :1; /* Flag to indicate the text is static*/
|
||||
}lv_label_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
/*Create function*/
|
||||
lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param);
|
||||
lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy);
|
||||
|
||||
/**
|
||||
* Create a label objects
|
||||
* @param par pointer to an object, it will be the parent of the new label
|
||||
* @param copy pointer to a button object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button
|
||||
*/
|
||||
lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the label
|
||||
* @param label pointer to a label object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a new text for a label. Memory will be allocated to store the text by the label.
|
||||
* @param label pointer to a label object
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Set a new text for a label from a character array. The array don't has to be '\0' terminated.
|
||||
* Memory will be allocated to store the array by the label.
|
||||
* @param label pointer to a label object
|
||||
* @param array array of characters or NULL to refresh the label
|
||||
* @param size the size of 'array' in bytes
|
||||
*/
|
||||
void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size);
|
||||
|
||||
/**
|
||||
* Set a static text. It will not be saved by the label so the 'text' variable
|
||||
* has to be 'alive' while the label exist.
|
||||
* @param label pointer to a label object
|
||||
* @param text pointer to a text. NULL to refresh with the current text.
|
||||
*/
|
||||
void lv_label_set_text_static(lv_obj_t * label, const char * text);
|
||||
|
||||
/**
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
* @param long_mode the new mode from 'lv_label_long_mode' enum.
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
|
||||
|
||||
/**
|
||||
* Get the text of a label
|
||||
* @param label pointer to a label object
|
||||
* @return the text of the label
|
||||
*/
|
||||
const char * lv_label_get_text(lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the fix width attribute of a label
|
||||
* @param label pointer to a label object
|
||||
* @return true: fix width is enabled
|
||||
*/
|
||||
lv_label_long_mode_t lv_label_get_long_mode(lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the relative x and y coordinates of a letter
|
||||
* @param label pointer to a label object
|
||||
* @param index index of the letter (0 ... text length)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos);
|
||||
|
||||
/**
|
||||
* Get the index of letter on a relative point of a label
|
||||
* @param label pointer to label object
|
||||
* @param pos pointer to point with coordinates on a the label
|
||||
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
|
||||
*/
|
||||
uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_labels_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_labels_t style
|
||||
*/
|
||||
lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -16,9 +16,11 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LED_BRIGHTNESS_DEF 128
|
||||
#define LV_LED_BRIGHTNESS_ON 50
|
||||
#define LV_LED_BRIGHTNESS_OFF 255
|
||||
#define LV_LED_WIDTH_DEF (30 * LV_DOWNSCALE)
|
||||
#define LV_LED_HEIGHT_DEF (30 * LV_DOWNSCALE)
|
||||
#define LV_LED_BRIGHT_DEF 128
|
||||
#define LV_LED_BRIGHT_OFF 60
|
||||
#define LV_LED_BRIGHT_ON 255
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -34,9 +36,10 @@ static void lv_leds_init(void);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
static lv_leds_t lv_leds_def; /*Red*/
|
||||
static lv_leds_t lv_leds_def;
|
||||
static lv_leds_t lv_leds_red;
|
||||
static lv_leds_t lv_leds_green;
|
||||
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -64,7 +67,9 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_led_ext_t * ext = lv_obj_alloc_ext(new_led, sizeof(lv_led_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->bright = LV_LED_BRIGHTNESS_DEF;
|
||||
ext->bright = LV_LED_BRIGHT_DEF;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_led);
|
||||
|
||||
lv_obj_set_signal_f(new_led, lv_led_signal);
|
||||
lv_obj_set_design_f(new_led, lv_led_design);
|
||||
@ -72,7 +77,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Init the new led object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_led, lv_leds_get(LV_LEDS_DEF, NULL));
|
||||
lv_obj_set_size_us(new_led, 40, 40);
|
||||
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
@ -140,7 +145,7 @@ void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
||||
*/
|
||||
void lv_led_on(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_bright(led, LV_LED_BRIGHTNESS_ON);
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +154,7 @@ void lv_led_on(lv_obj_t * led)
|
||||
*/
|
||||
void lv_led_off(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_bright(led, LV_LED_BRIGHTNESS_OFF);
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
||||
}
|
||||
|
||||
|
||||
@ -160,7 +165,7 @@ void lv_led_off(lv_obj_t * led)
|
||||
void lv_led_tgl(lv_obj_t * led)
|
||||
{
|
||||
uint8_t bright = lv_led_get_bright(led);
|
||||
if(bright > 60) lv_led_off(led);
|
||||
if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1) lv_led_off(led);
|
||||
else lv_led_on(led);
|
||||
}
|
||||
|
||||
@ -199,9 +204,11 @@ lv_leds_t * lv_leds_get(lv_leds_builtin_t style, lv_leds_t * copy)
|
||||
|
||||
switch(style) {
|
||||
case LV_LEDS_DEF:
|
||||
case LV_LEDS_RED:
|
||||
style_p = &lv_leds_def;
|
||||
break;
|
||||
case LV_LEDS_RED:
|
||||
style_p = &lv_leds_red;
|
||||
break;
|
||||
case LV_LEDS_GREEN:
|
||||
style_p = &lv_leds_green;
|
||||
break;
|
||||
@ -234,24 +241,30 @@ lv_leds_t * lv_leds_get(lv_leds_builtin_t style, lv_leds_t * copy)
|
||||
static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return false;
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(led, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Make darker colors in a temporary style according to the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
lv_leds_t * style = lv_obj_get_style(led);
|
||||
lv_leds_t leds_tmp;
|
||||
|
||||
/*Create a temporal style*/
|
||||
lv_leds_t leds_tmp;
|
||||
memcpy(&leds_tmp, style, sizeof(leds_tmp));
|
||||
|
||||
/*Mix. the color with black proportionally with brightness*/
|
||||
leds_tmp.bg_rect.objs.color = color_mix(leds_tmp.bg_rect.objs.color, COLOR_BLACK, ext->bright);
|
||||
leds_tmp.bg_rect.gcolor = color_mix(leds_tmp.bg_rect.gcolor, COLOR_BLACK, ext->bright);
|
||||
|
||||
opa_t opa = lv_obj_get_opa(led);
|
||||
area_t area;
|
||||
lv_obj_get_cords(led, &area);
|
||||
/*Set smaller light size with lower brightness*/
|
||||
/*light = 0 comes to LV_LED_BRIGHTNESS_OFF and the original light comes to LV_LED_BRIGHTNESS_ON*/
|
||||
leds_tmp.bg_rect.light = (uint16_t)((uint16_t)(ext->bright - LV_LED_BRIGHT_OFF) * style->bg_rect.light) /
|
||||
(LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF);
|
||||
|
||||
lv_draw_rect(&area, mask, &leds_tmp.bg_rect, opa);
|
||||
|
||||
led->style_p = &leds_tmp;
|
||||
ancestor_design_f(led, mask, mode);
|
||||
led->style_p = style;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -261,23 +274,29 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
|
||||
*/
|
||||
static void lv_leds_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
/*Default style (red)*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_leds_def.bg_rect);
|
||||
lv_leds_def.bg_rect.objs.color = COLOR_RED;
|
||||
lv_leds_def.bg_rect.gcolor = COLOR_MARRON,
|
||||
lv_leds_def.bg_rect.bcolor = COLOR_WHITE;
|
||||
lv_leds_def.bg_rect.bcolor = COLOR_MAKE(0x40, 0x00, 0x00);
|
||||
lv_leds_def.bg_rect.lcolor = COLOR_RED;
|
||||
lv_leds_def.bg_rect.bwidth = 4 * LV_DOWNSCALE;
|
||||
lv_leds_def.bg_rect.bopa = 50;
|
||||
lv_leds_def.bg_rect.light = 15 * LV_DOWNSCALE;
|
||||
lv_leds_def.bg_rect.round = LV_RECT_CIRCLE;
|
||||
lv_leds_def.bg_rect.hpad = 0;
|
||||
lv_leds_def.bg_rect.vpad = 0;
|
||||
lv_leds_def.bg_rect.opad = 0;
|
||||
|
||||
/*Red style*/
|
||||
memcpy(&lv_leds_red, &lv_leds_def, sizeof(lv_leds_t));
|
||||
|
||||
/* Green style */
|
||||
memcpy(&lv_leds_green, &lv_leds_def, sizeof(lv_leds_t));
|
||||
lv_leds_green.bg_rect.objs.color = COLOR_LIME;
|
||||
lv_leds_green.bg_rect.gcolor = COLOR_GREEN;
|
||||
lv_leds_green.bg_rect.bcolor = COLOR_WHITE;
|
||||
lv_leds_green.bg_rect.bcolor = COLOR_MAKE(0x00, 0x40, 0x00);
|
||||
lv_leds_green.bg_rect.lcolor = COLOR_LIME;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -27,6 +27,14 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of led*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t bright; /*Current brightness of the LED*/
|
||||
}lv_led_ext_t;
|
||||
|
||||
/*Style of led*/
|
||||
typedef struct
|
||||
{
|
||||
@ -42,27 +50,66 @@ typedef enum
|
||||
LV_LEDS_GREEN,
|
||||
}lv_leds_builtin_t;
|
||||
|
||||
/*Data of led*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t bright; /*Current brightness of the LED*/
|
||||
}lv_led_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param);
|
||||
lv_leds_t * lv_leds_get(lv_leds_builtin_t style, lv_leds_t * copy);
|
||||
|
||||
/**
|
||||
* Create a led objects
|
||||
* @param par pointer to an object, it will be the parent of the new led
|
||||
* @param copy pointer to a led object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created led
|
||||
*/
|
||||
lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the led
|
||||
* @param led pointer to a led object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the brightness of a LED object
|
||||
* @param led pointer to a LED object
|
||||
* @param bright 0 (max. dark) ... 255 (max. light)
|
||||
*/
|
||||
void lv_led_set_bright(lv_obj_t * led, uint8_t bright);
|
||||
|
||||
/**
|
||||
* Light on a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_on(lv_obj_t * led);
|
||||
|
||||
/**
|
||||
* Light off a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_off(lv_obj_t * led);
|
||||
|
||||
/**
|
||||
* Toggle the state of a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_tgl(lv_obj_t * led);
|
||||
|
||||
/**
|
||||
* Get the brightness of a LEd object
|
||||
* @param led pointer to LED object
|
||||
* @return bright 0 (max. dark) ... 255 (max. light)
|
||||
*/
|
||||
uint8_t lv_led_get_bright(lv_obj_t * led);
|
||||
|
||||
void lv_led_on(lv_obj_t * led);
|
||||
void lv_led_off(lv_obj_t * led);
|
||||
void lv_led_tgl(lv_obj_t * led);
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_leds_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_leds_t style
|
||||
*/
|
||||
lv_leds_t * lv_leds_get(lv_leds_builtin_t style, lv_leds_t * copy);
|
||||
|
||||
|
||||
/**********************
|
||||
|
@ -145,8 +145,8 @@ void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point
|
||||
cord_t xmax = LV_CORD_MIN;
|
||||
cord_t ymax = LV_CORD_MIN;
|
||||
for(i = 0; i < point_num; i++) {
|
||||
xmax = max(point_a[i].x * us, xmax);
|
||||
ymax = max(point_a[i].y * us, ymax);
|
||||
xmax = MATH_MAX(point_a[i].x * us, xmax);
|
||||
ymax = MATH_MAX(point_a[i].y * us, ymax);
|
||||
}
|
||||
|
||||
lv_lines_t * lines = lv_obj_get_style(line);
|
||||
|
@ -21,6 +21,18 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of line*/
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
|
||||
const point_t * point_array; /*Pointer to an array with the points of the line*/
|
||||
uint16_t point_num; /*Number of points in 'point_array' */
|
||||
uint8_t auto_size :1; /*1: set obj. width to x max and obj. height to y max */
|
||||
uint8_t y_inv :1; /*1: y == 0 will be on the bottom*/
|
||||
uint8_t upscale :1; /*1: upscale coordinates with LV_DOWNSCALE*/
|
||||
}lv_line_ext_t;
|
||||
|
||||
/*Style of line*/
|
||||
typedef struct
|
||||
{
|
||||
@ -37,31 +49,88 @@ typedef enum
|
||||
LV_LINES_CHART,
|
||||
}lv_lines_builtin_t;
|
||||
|
||||
/*Data of line*/
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so inherited ext.*/ /*Ext. of ancestor*/
|
||||
const point_t * point_array;
|
||||
uint16_t point_num;
|
||||
uint8_t auto_size :1;
|
||||
uint8_t y_inv :1;
|
||||
uint8_t upscale :1;
|
||||
}lv_line_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Create a line objects
|
||||
* @param par pointer to an object, it will be the parent of the new line
|
||||
* @return pointer to the created line
|
||||
*/
|
||||
lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the line
|
||||
* @param line pointer to a line object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param);
|
||||
lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy);
|
||||
|
||||
/**
|
||||
* Set an array of points. The line object will connect these points.
|
||||
* @param line pointer to a line object
|
||||
* @param point_a an array of points. Only the address is saved,
|
||||
* so the array can be a local variable which will be destroyed
|
||||
* @param point_num number of points in 'point_a'
|
||||
*/
|
||||
void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point_num);
|
||||
|
||||
/**
|
||||
* Enable (or disable) the auto-size option. The size of the object will fit to its points.
|
||||
* (set width to x max and height to y max)
|
||||
* @param line pointer to a line object
|
||||
* @param autosize true: auto size is enabled, false: auto size is disabled
|
||||
*/
|
||||
void lv_line_set_auto_size(lv_obj_t * line, bool autosize);
|
||||
|
||||
/**
|
||||
* Enable (or disable) the y coordinate inversion.
|
||||
* If enabled then y will be subtracted from the height of the object,
|
||||
* therefore the y=0 coordinate will be on the bottom.
|
||||
* @param line pointer to a line object
|
||||
* @param yinv true: enable the y inversion, false:disable the y inversion
|
||||
*/
|
||||
void lv_line_set_y_inv(lv_obj_t * line, bool yinv);
|
||||
|
||||
/**
|
||||
* Enable (or disable) the point coordinate upscaling (compensate LV_DOWNSCALE).
|
||||
* @param line pointer to a line object
|
||||
* @param unscale true: enable the point coordinate upscaling
|
||||
*/
|
||||
void lv_line_set_upscale(lv_obj_t * line, bool unscale);
|
||||
|
||||
/**
|
||||
* Get the auto size attribute
|
||||
* @param line pointer to a line object
|
||||
* @return true: auto size is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_auto_size(lv_obj_t * line);
|
||||
|
||||
/**
|
||||
* Get the y inversion attribute
|
||||
* @param line pointer to a line object
|
||||
* @return true: y inversion is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_y_inv(lv_obj_t * line);
|
||||
|
||||
/**
|
||||
* Get the point upscale enable attribute
|
||||
* @param obj pointer to a line object
|
||||
* @return true: point coordinate upscale is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_upscale(lv_obj_t * line);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_lines_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_lines_t style
|
||||
*/
|
||||
lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -114,7 +114,6 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_lists_t * lists = lv_obj_get_style(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
/*Create a list element with the image an the text*/
|
||||
lv_obj_t * liste;
|
||||
|
@ -38,17 +38,24 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of list*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
/*No new data*/
|
||||
}lv_list_ext_t;
|
||||
|
||||
/*Style of list*/
|
||||
typedef struct
|
||||
{
|
||||
lv_pages_t bg_pages; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
lv_btns_t liste_btns;
|
||||
lv_labels_t liste_labels;
|
||||
lv_imgs_t liste_imgs;
|
||||
lv_rect_layout_t liste_layout;
|
||||
uint8_t widthe_sb :1; /*Keep space for the scrollbar*/
|
||||
lv_btns_t liste_btns; /*List element button style*/
|
||||
lv_labels_t liste_labels; /*List element label style*/
|
||||
lv_imgs_t liste_imgs; /*List element image style*/
|
||||
lv_rect_layout_t liste_layout; /*List element layout (will be removed)*/
|
||||
uint8_t widthe_sb :1; /*1: Keep space for the scrollbar*/
|
||||
}lv_lists_t;
|
||||
|
||||
/*Built-in styles of list*/
|
||||
@ -59,26 +66,63 @@ typedef enum
|
||||
LV_LISTS_TRANSP,
|
||||
}lv_lists_builtin_t;
|
||||
|
||||
/*Data of list*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
/*No new data*/
|
||||
}lv_list_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action);
|
||||
lv_lists_t * lv_lists_get(lv_lists_builtin_t style, lv_lists_t * copy);
|
||||
|
||||
void lv_list_down(lv_obj_t * list);
|
||||
/**
|
||||
* Create a list objects
|
||||
* @param par pointer to an object, it will be the parent of the new list
|
||||
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created list
|
||||
*/
|
||||
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the list
|
||||
* @param list pointer to a list object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Add a list element to the list
|
||||
* @param list pointer to list object
|
||||
* @param img_fn file name of an image before the text (NULL if unused)
|
||||
* @param txt text of the list element (NULL if unused)
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Move the list elements up by one
|
||||
* @param list pointer a to list object
|
||||
*/
|
||||
void lv_list_up(lv_obj_t * list);
|
||||
|
||||
/**
|
||||
* Move the list elements down by one
|
||||
* @param list pointer to a list object
|
||||
*/
|
||||
void lv_list_down(lv_obj_t * list);
|
||||
|
||||
/**
|
||||
* Get the text of a list element
|
||||
* @param liste pointer to list element
|
||||
* @return pointer to the text
|
||||
*/
|
||||
const char * lv_list_element_get_txt(lv_obj_t * liste);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_lists_builtin_t enum
|
||||
* @param copy_p copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_lists_t style
|
||||
*/
|
||||
lv_lists_t * lv_lists_get(lv_lists_builtin_t style, lv_lists_t * list);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -12,10 +12,15 @@
|
||||
|
||||
#include "lv_mbox.h"
|
||||
#include "../lv_misc/anim.h"
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MBOX_CLOSE_FADE_TIME 750 /*ms*/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_MBOX_ANIM_TIME
|
||||
#define LV_MBOX_ANIM_TIME 250 /*How fast animate out the message box in auto close. 0: no animation [ms]*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -29,11 +34,15 @@ static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_
|
||||
#endif
|
||||
static void lv_mboxs_init(void);
|
||||
static void lv_mbox_realign(lv_obj_t * mbox);
|
||||
static void lv_mbox_disable_fit(lv_obj_t * mbox);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_mboxs_t lv_mboxs_def; /*Default message box style*/
|
||||
static lv_mboxs_t lv_mboxs_info;
|
||||
static lv_mboxs_t lv_mboxs_warn;
|
||||
static lv_mboxs_t lv_mboxs_err;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -83,6 +92,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->btnh = lv_rect_create(new_mbox, NULL);
|
||||
lv_rect_set_fit(ext->btnh, false, true);
|
||||
lv_rect_set_layout(ext->btnh, LV_RECT_LAYOUT_PRETTY);
|
||||
lv_obj_set_hidden(ext->btnh, true); /*Initially hidden, the first button will unhide it */
|
||||
|
||||
lv_obj_set_style(new_mbox, lv_mboxs_get(LV_MBOXS_DEF, NULL));
|
||||
}
|
||||
@ -93,6 +103,17 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->txt = lv_label_create(new_mbox, copy_ext->txt);
|
||||
ext->btnh = lv_rect_create(new_mbox, copy_ext->btnh);
|
||||
|
||||
/*Copy the buttons and the label on them*/
|
||||
lv_obj_t * btn;
|
||||
lv_obj_t * new_btn;
|
||||
btn = lv_obj_get_child(copy_ext->btnh, NULL);
|
||||
while(btn != NULL) {
|
||||
new_btn = lv_btnm_create(ext->btnh, btn);
|
||||
lv_label_create(new_btn, lv_obj_get_child(btn, NULL));
|
||||
|
||||
btn = lv_obj_get_child(copy_ext->btnh, btn);
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_mbox);
|
||||
}
|
||||
@ -134,6 +155,15 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_LONG_PRESS:
|
||||
#if LV_MBOX_ANIM_TIME != 0
|
||||
lv_mbox_start_auto_close(mbox, 0);
|
||||
#else
|
||||
lv_obj_del(mbox);
|
||||
valid = false;
|
||||
#endif
|
||||
lv_dispi_wait_release(param);
|
||||
break;
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
lv_obj_set_style(ext->title, &style->title);
|
||||
lv_obj_set_style(ext->txt, &style->txt);
|
||||
@ -144,7 +174,6 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
while(btn != NULL) {
|
||||
/*Refresh the next button's style*/
|
||||
lv_obj_set_style(btn, &style->btn);
|
||||
lv_obj_set_size(btn, style->btn_w, style->btn_h);
|
||||
|
||||
/*Refresh the button label too*/
|
||||
lv_obj_set_style(lv_obj_get_child(btn, NULL), &style->btn_label);
|
||||
@ -152,13 +181,13 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
}
|
||||
|
||||
/*Hide the title and/or buttons*/
|
||||
lv_obj_set_hidden(ext->title, style->hide_title == 0 ? false : true);
|
||||
const char * title_txt = lv_label_get_text(ext->title);
|
||||
if(title_txt[0] == '\0') lv_obj_set_hidden(ext->btnh, true);
|
||||
else lv_obj_set_hidden(ext->btnh, false);
|
||||
|
||||
if(lv_obj_get_child_num(ext->btnh) == 0) lv_obj_set_hidden(ext->btnh, true);
|
||||
else lv_obj_set_hidden(ext->btnh, false);
|
||||
|
||||
if(style->hide_btns != 0 || lv_obj_get_child_num(ext->btnh) != 0) {
|
||||
lv_obj_set_hidden(ext->btnh, true);
|
||||
} else {
|
||||
lv_obj_set_hidden(ext->btnh, false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -172,6 +201,37 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
|
||||
/*Hide the title if it is an empty text*/
|
||||
if(title[0] == '\0') lv_obj_set_hidden(ext->title, true);
|
||||
else if (lv_obj_get_hidden(ext->title) != false) lv_obj_set_hidden(ext->title, false);
|
||||
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->txt, txt);
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a button to the message box
|
||||
* @param mbox pointer to message box object
|
||||
@ -188,21 +248,24 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
btn = lv_btn_create(ext->btnh, NULL);
|
||||
lv_btn_set_rel_action(btn, rel_action);
|
||||
lv_obj_set_style(btn, &style->btn);
|
||||
lv_obj_set_size(btn, style->btn_w, style->btn_h);
|
||||
lv_rect_set_fit(btn, true, true);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(btn, NULL);
|
||||
lv_obj_set_style(label, &style->btn_label);
|
||||
lv_label_set_text(label, btn_txt);
|
||||
|
||||
/*With 1 button set center layout but from 3 set grid*/
|
||||
/*With 1 button set center layout but from 2 set pretty*/
|
||||
uint16_t child_num = lv_obj_get_child_num(ext->btnh);
|
||||
if(child_num == 1) {
|
||||
lv_obj_set_hidden(ext->btnh, false);
|
||||
lv_rect_set_layout(ext->btnh, LV_RECT_LAYOUT_CENTER);
|
||||
} else if (child_num == 2) {
|
||||
lv_rect_set_layout(ext->btnh, LV_RECT_LAYOUT_PRETTY);
|
||||
}
|
||||
|
||||
lv_mbox_realign(mbox);
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
@ -210,15 +273,15 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
* A release action which can be assigned to a message box button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always false because the button is deleted with the mesage box
|
||||
* @return always lv_action_res_t because the button is deleted with the mesage box
|
||||
*/
|
||||
bool lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
lv_action_res_t lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_t * mbox = lv_mbox_get_from_btn(btn);
|
||||
|
||||
lv_obj_del(mbox);
|
||||
|
||||
return false;
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,38 +289,30 @@ bool lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
* @param mbox pointer to a message box object
|
||||
* @param tout a time (in milliseconds) to wait before delete the message box
|
||||
*/
|
||||
void lv_mbox_auto_close(lv_obj_t * mbox, uint16_t tout)
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout)
|
||||
{
|
||||
#if LV_MBOX_ANIM_TIME != 0
|
||||
/*Add shrinking animations*/
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_H| ANIM_OUT, LV_MBOX_ANIM_TIME, tout, NULL);
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_V| ANIM_OUT, LV_MBOX_ANIM_TIME, tout, lv_obj_del);
|
||||
|
||||
lv_obj_anim(mbox, LV_ANIM_FADE | ANIM_OUT, LV_MBOX_CLOSE_FADE_TIME, tout, lv_obj_del);
|
||||
}
|
||||
/*When the animations start disable fit to let shrinking work*/
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, 1, tout, lv_mbox_disable_fit);
|
||||
|
||||
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
#else
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, LV_MBOX_ANIM_TIME, tout, lv_obj_del);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
* Stop the auto. closing of message box
|
||||
* @param mbox pointer to a message box object
|
||||
*/
|
||||
void lv_mbox_set_txt(lv_obj_t * mbox, const char * txt)
|
||||
void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->txt, txt);
|
||||
anim_del(mbox, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -321,12 +376,17 @@ lv_mboxs_t * lv_mboxs_get(lv_mboxs_builtin_t style, lv_mboxs_t * copy)
|
||||
|
||||
switch(style) {
|
||||
case LV_MBOXS_DEF:
|
||||
case LV_MBOXS_INFO:
|
||||
case LV_MBOXS_WARN:
|
||||
case LV_MBOXS_ERR:
|
||||
case LV_MBOXS_BUBBLE:
|
||||
style_p = &lv_mboxs_def;
|
||||
break;
|
||||
case LV_MBOXS_INFO:
|
||||
style_p = &lv_mboxs_info;
|
||||
break;
|
||||
case LV_MBOXS_WARN:
|
||||
style_p = &lv_mboxs_warn;
|
||||
break;
|
||||
case LV_MBOXS_ERR:
|
||||
style_p = &lv_mboxs_err;
|
||||
break;
|
||||
default:
|
||||
style_p = &lv_mboxs_def;
|
||||
}
|
||||
@ -370,6 +430,43 @@ static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Realign the elements of the message box
|
||||
* @param mbox pointer to message box object
|
||||
*/
|
||||
static void lv_mbox_realign(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
if(ext->btnh == NULL || ext->title == NULL || ext->txt == NULL) return;
|
||||
|
||||
/*Set the button holder width to the width of the text and title*/
|
||||
if(lv_obj_get_hidden(ext->btnh) == false) {
|
||||
cord_t title_w = lv_obj_get_width(ext->title);
|
||||
cord_t txt_w = lv_obj_get_width(ext->txt);
|
||||
cord_t btn_w = 0;
|
||||
lv_obj_t * btn;
|
||||
btn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(btn != NULL) {
|
||||
btn_w = MATH_MAX(lv_obj_get_width(btn), btn_w);
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
|
||||
cord_t w = MATH_MAX(title_w, txt_w);
|
||||
w = MATH_MAX(w, btn_w);
|
||||
lv_obj_set_width(ext->btnh, w );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CAlled when the close animations starts to disable the recargle's fit
|
||||
* @param mbox ppointer to message box object
|
||||
*/
|
||||
static void lv_mbox_disable_fit(lv_obj_t * mbox)
|
||||
{
|
||||
lv_rect_set_fit(mbox, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the message box styles
|
||||
*/
|
||||
@ -377,7 +474,7 @@ static void lv_mboxs_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_mboxs_def.bg);
|
||||
lv_mboxs_def.bg.light = 10 * LV_DOWNSCALE;
|
||||
lv_mboxs_def.bg.light = 8 * LV_DOWNSCALE;
|
||||
|
||||
lv_btns_get(LV_BTNS_DEF, &lv_mboxs_def.btn);
|
||||
lv_mboxs_def.btn.flags[LV_BTN_STATE_PR].light_en = 0;
|
||||
@ -389,27 +486,43 @@ static void lv_mboxs_init(void)
|
||||
lv_mboxs_def.btnh.hpad = 0;
|
||||
lv_mboxs_def.btnh.vpad = 0;
|
||||
|
||||
lv_mboxs_def.btn_w = 80 * LV_DOWNSCALE;
|
||||
lv_mboxs_def.btn_h = 50 * LV_DOWNSCALE;
|
||||
lv_mboxs_def.hide_btns = 0;
|
||||
lv_mboxs_def.hide_title = 0;
|
||||
memcpy(&lv_mboxs_info, &lv_mboxs_def, sizeof(lv_mboxs_t));
|
||||
lv_mboxs_info.bg.objs.color = COLOR_BLACK;
|
||||
lv_mboxs_info.bg.gcolor = COLOR_BLACK;
|
||||
lv_mboxs_info.bg.bcolor = COLOR_WHITE;
|
||||
lv_mboxs_info.title.objs.color = COLOR_WHITE;
|
||||
lv_mboxs_info.txt.objs.color = COLOR_WHITE;
|
||||
lv_mboxs_info.txt.letter_space = 2 * LV_DOWNSCALE;
|
||||
|
||||
/*TODO add further styles*/
|
||||
lv_btns_get(LV_BTNS_BORDER, &lv_mboxs_info.btn);
|
||||
lv_mboxs_info.btn.bcolor[LV_BTN_STATE_PR] = COLOR_SILVER;
|
||||
lv_mboxs_info.btn.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE;
|
||||
lv_mboxs_info.btn.mcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
lv_mboxs_info.btn.gcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
lv_mboxs_info.btn.rects.bopa = OPA_COVER;
|
||||
lv_mboxs_info.btn_label.objs.color = COLOR_WHITE;
|
||||
|
||||
memcpy(&lv_mboxs_warn, &lv_mboxs_info, sizeof(lv_mboxs_t));
|
||||
lv_mboxs_warn.bg.objs.color = COLOR_MAKE(0xff, 0xb2, 0x66);
|
||||
lv_mboxs_warn.bg.gcolor = COLOR_MAKE(0xff, 0xad, 0x29);
|
||||
lv_mboxs_warn.btn.bcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x10, 0x10, 0x10);
|
||||
lv_mboxs_warn.btn.bcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x10, 0x10, 0x10);
|
||||
lv_mboxs_warn.btn.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xa8, 0x6e, 0x33);
|
||||
lv_mboxs_warn.btn.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xa8, 0x6e, 0x33);
|
||||
lv_mboxs_warn.title.objs.color = COLOR_MAKE(0x10, 0x10, 0x10);
|
||||
lv_mboxs_warn.txt.objs.color = COLOR_MAKE(0x10, 0x10, 0x10);;
|
||||
lv_mboxs_warn.btn_label.objs.color = COLOR_MAKE(0x10, 0x10, 0x10);
|
||||
|
||||
memcpy(&lv_mboxs_err, &lv_mboxs_warn, sizeof(lv_mboxs_t));
|
||||
lv_mboxs_err.bg.objs.color = COLOR_MAKE(0xff, 0x66, 0x66);
|
||||
lv_mboxs_err.bg.gcolor = COLOR_MAKE(0x99, 0x22, 0x22);
|
||||
lv_mboxs_err.btn.bcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
lv_mboxs_err.btn.bcolor[LV_BTN_STATE_PR] = COLOR_BLACK;
|
||||
lv_mboxs_err.btn.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x70, 0x00, 0x00);
|
||||
lv_mboxs_err.btn.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x70, 0x00, 0x00);
|
||||
lv_mboxs_err.title.objs.color = COLOR_BLACK;
|
||||
lv_mboxs_err.txt.objs.color = COLOR_BLACK;
|
||||
lv_mboxs_err.btn_label.objs.color = COLOR_BLACK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Realign the elements of the message box
|
||||
* @param mbox pointer to message box object
|
||||
*/
|
||||
static void lv_mbox_realign(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mboxs_t * style = lv_obj_get_style(mbox);
|
||||
|
||||
if(ext->btnh == NULL || ext->title == NULL || ext->txt == NULL) return;
|
||||
|
||||
lv_obj_set_width(ext->btnh, lv_obj_get_width(mbox) - 2 * style->bg.hpad);
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
@ -39,20 +39,27 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of message box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * title; /*Title of the message box*/
|
||||
lv_obj_t * txt; /*Text of the message box*/
|
||||
lv_obj_t * btnh; /*Holder of the buttons*/
|
||||
}lv_mbox_ext_t;
|
||||
|
||||
|
||||
/*Style of message box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t bg; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
lv_labels_t title;
|
||||
lv_labels_t txt;
|
||||
lv_rects_t btnh;
|
||||
lv_btns_t btn;
|
||||
lv_labels_t btn_label;
|
||||
cord_t btn_w;
|
||||
cord_t btn_h;
|
||||
uint8_t hide_title :1;
|
||||
uint8_t hide_btns :1;
|
||||
lv_labels_t title; /*Style of the title*/
|
||||
lv_labels_t txt; /*Style of the text*/
|
||||
lv_rects_t btnh; /*Style of the button holder*/
|
||||
lv_btns_t btn; /*Style of the buttons*/
|
||||
lv_labels_t btn_label; /*Style of the label on the buttons*/
|
||||
}lv_mboxs_t;
|
||||
|
||||
/*Built-in styles of message box*/
|
||||
@ -62,36 +69,102 @@ typedef enum
|
||||
LV_MBOXS_INFO,
|
||||
LV_MBOXS_WARN,
|
||||
LV_MBOXS_ERR,
|
||||
LV_MBOXS_BUBBLE,
|
||||
}lv_mboxs_builtin_t;
|
||||
|
||||
/*Data of message box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * txt;
|
||||
lv_obj_t * btnh;
|
||||
}lv_mbox_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a message box objects
|
||||
* @param par pointer to an object, it will be the parent of the new message box
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
|
||||
lv_mboxs_t * lv_mboxs_get(lv_mboxs_builtin_t style, lv_mboxs_t * copy);
|
||||
|
||||
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action);
|
||||
bool lv_mbox_close_action (lv_obj_t * mbox, lv_dispi_t *dispi);
|
||||
void lv_mbox_auto_close(lv_obj_t * mbox, uint16_t tout);
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title);
|
||||
void lv_mbox_set_txt(lv_obj_t * mbox, const char * txt);
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
|
||||
|
||||
/**
|
||||
* Add a button to the message box
|
||||
* @param mbox pointer to message box object
|
||||
* @param btn_txt the text of the button
|
||||
* @param rel_action a function which will be called when the button is relesed
|
||||
* @return pointer to the created button (lv_btn)
|
||||
*/
|
||||
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* A release action which can be assigned to a message box button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always LV_ACTION_RES_INV because the button is deleted with the message box
|
||||
*/
|
||||
lv_action_res_t lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Automatically delete the message box after a given time
|
||||
* @param mbox pointer to a message box object
|
||||
* @param tout a time (in milliseconds) to wait before delete the message box
|
||||
*/
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout);
|
||||
|
||||
/**
|
||||
* Stop the auto. closing of message box
|
||||
* @param mbox pointer to a message box object
|
||||
*/
|
||||
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
|
||||
|
||||
/**
|
||||
* get the title of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @return pointer to the title of the message box
|
||||
*/
|
||||
const char * lv_mbox_get_title(lv_obj_t * mbox);
|
||||
|
||||
/**
|
||||
* Get the text of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @return pointer to the text of the message box
|
||||
*/
|
||||
const char * lv_mbox_get_txt(lv_obj_t * mbox);
|
||||
|
||||
/**
|
||||
* Get the message box object from one of its button.
|
||||
* It is useful in the button release actions where only the button is known
|
||||
* @param btn pointer to a button of a message box
|
||||
* @return pointer to the button's message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_mboxs_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_mboxs_t style
|
||||
*/
|
||||
lv_mboxs_t * lv_mboxs_get(lv_mboxs_builtin_t style, lv_mboxs_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -29,7 +29,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_temps_init(void);
|
||||
static void lv_templs_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -138,7 +138,7 @@ lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy)
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_temps_init();
|
||||
lv_templs_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mod
|
||||
/**
|
||||
* Initialize the built-in template styles
|
||||
*/
|
||||
static void lv_temps_init(void)
|
||||
static void lv_templs_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
}
|
||||
|
@ -28,6 +28,12 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of template*/
|
||||
typedef struct
|
||||
{
|
||||
/*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
}lv_templ_ext_t;
|
||||
|
||||
/*Style of template*/
|
||||
typedef struct
|
||||
@ -42,18 +48,33 @@ typedef enum
|
||||
LV_TEMPLS_DEF,
|
||||
}lv_templs_builtin_t;
|
||||
|
||||
/*Data of template*/
|
||||
typedef struct
|
||||
{
|
||||
/*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
}lv_templ_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a template objects
|
||||
* @param par pointer to an object, it will be the parent of the new template
|
||||
* @param copy pointer to a template object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created template
|
||||
*/
|
||||
lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the template
|
||||
* @param templ pointer to a template object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_templs_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_templs_t style
|
||||
*/
|
||||
lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy);
|
||||
|
||||
/**********************
|
||||
|
@ -19,6 +19,10 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_PAGE_ANIM_FOCUS_TIME
|
||||
#define LV_PAGE_ANIM_FOCUS_TIME 300 /*List focus animation time [ms] (0: turn off the animation)*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -277,8 +281,8 @@ static bool lv_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void* param)
|
||||
|
||||
case LV_SIGNAL_DRAG_BEGIN:
|
||||
if(style->sb_mode == LV_PAGE_SB_MODE_DRAG ) {
|
||||
cord_t sbh_pad = max(style->sb_width, style->bg_rects.hpad);
|
||||
cord_t sbv_pad = max(style->sb_width, style->bg_rects.vpad);
|
||||
cord_t sbh_pad = MATH_MAX(style->sb_width, style->bg_rects.hpad);
|
||||
cord_t sbv_pad = MATH_MAX(style->sb_width, style->bg_rects.vpad);
|
||||
if(area_get_height(&page_ext->sbv) < lv_obj_get_height(scrl) - 2 * sbv_pad) {
|
||||
page_ext->sbv_draw = 1;
|
||||
}
|
||||
@ -565,8 +569,8 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
cord_t vpad = style->bg_rects.vpad;
|
||||
cord_t obj_w = lv_obj_get_width(page);
|
||||
cord_t obj_h = lv_obj_get_height(page);
|
||||
cord_t sbh_pad = max(style->sb_width, style->bg_rects.hpad);
|
||||
cord_t sbv_pad = max(style->sb_width, style->bg_rects.vpad);
|
||||
cord_t sbh_pad = MATH_MAX(style->sb_width, style->bg_rects.hpad);
|
||||
cord_t sbv_pad = MATH_MAX(style->sb_width, style->bg_rects.vpad);
|
||||
|
||||
if(style->sb_mode == LV_PAGE_SB_MODE_OFF) return;
|
||||
|
||||
|
@ -27,25 +27,40 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of page*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * scrl; /*The scrollable object on the background*/
|
||||
lv_action_t rel_action; /*Release action*/
|
||||
lv_action_t pr_action; /*Press action*/
|
||||
area_t sbh; /*Horizontal scrollbar area (relative to the page) */
|
||||
area_t sbv; /*Vertical scrollbar area (relative to the page)*/
|
||||
uint8_t sbh_draw :1; /*1: horizontal scrollbar is visible now*/
|
||||
uint8_t sbv_draw :1; /*1: vertical scrollbar is visible now*/
|
||||
}lv_page_ext_t;
|
||||
|
||||
/*Scrollbar modes: shows when should the scrollbars be visible*/
|
||||
typedef enum
|
||||
{
|
||||
LV_PAGE_SB_MODE_OFF,
|
||||
LV_PAGE_SB_MODE_ON,
|
||||
LV_PAGE_SB_MODE_DRAG,
|
||||
LV_PAGE_SB_MODE_AUTO,
|
||||
LV_PAGE_SB_MODE_OFF, /*Never show scrollbars*/
|
||||
LV_PAGE_SB_MODE_ON, /*Always show scrollbars*/
|
||||
LV_PAGE_SB_MODE_DRAG, /*Show scrollbars when page is being dragged*/
|
||||
LV_PAGE_SB_MODE_AUTO, /*Show scrollbars when the scrollable rect. is large enough to be scrolled*/
|
||||
}lv_page_sb_mode_t;
|
||||
|
||||
|
||||
/*Style of page*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t bg_rects; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
lv_rects_t scrl_rects;
|
||||
lv_rects_t sb_rects;
|
||||
cord_t sb_width;
|
||||
lv_page_sb_mode_t sb_mode;
|
||||
uint8_t sb_opa;
|
||||
lv_rects_t scrl_rects; /*Style of the scrollable rectangle*/
|
||||
lv_rects_t sb_rects; /*Style of scrollbars*/
|
||||
cord_t sb_width; /*Width of the scrollbars*/
|
||||
lv_page_sb_mode_t sb_mode; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/
|
||||
uint8_t sb_opa; /*Opacity of scrollbars in percentage of object opacity (0..100)*/
|
||||
}lv_pages_t;
|
||||
|
||||
/*Built-in styles of page*/
|
||||
@ -56,35 +71,70 @@ typedef enum
|
||||
LV_PAGES_TRANSP,
|
||||
}lv_pages_builtin_t;
|
||||
|
||||
/*Data of page*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * scrl; /*The scrollable object on the background*/
|
||||
lv_action_t rel_action;
|
||||
lv_action_t pr_action;
|
||||
area_t sbh; /*Horizontal scrollbar*/
|
||||
area_t sbv; /*Vertical scrollbar*/
|
||||
uint8_t sbh_draw :1; /*1: horizontal scrollbar is visible now*/
|
||||
uint8_t sbv_draw :1; /*1: vertical scrollbar is visible now*/
|
||||
}lv_page_ext_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
/*Create function*/
|
||||
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * copy);
|
||||
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Create a page objects
|
||||
* @param par pointer to an object, it will be the parent of the new page
|
||||
* @param copy pointer to a page object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created page
|
||||
*/
|
||||
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the page
|
||||
* @param page pointer to a page object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a release action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param rel_action a function to call when the page is released
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set a press action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param pr_action a function to call when the page is pressed
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action);
|
||||
|
||||
/**
|
||||
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
|
||||
* @param obj pointer to an object on a page
|
||||
* @param glue true: enable glue, false: disable glue
|
||||
*/
|
||||
void lv_page_glue_obj(lv_obj_t * obj, bool glue);
|
||||
|
||||
/**
|
||||
* Focus on an object. It ensures that the object will be visible on the page.
|
||||
* @param page pointer to a page object
|
||||
* @param obj pointer to an object to focus (must be on the page)
|
||||
* @param anim_en true: scroll with animation
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, bool anim_en);
|
||||
|
||||
/**
|
||||
* Get the scrollable object of a page-
|
||||
* @param page pointer to page object
|
||||
* @return pointer to rectangle which is the scrollable part of the page
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_pages_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_pages_t style
|
||||
*/
|
||||
lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -33,12 +33,24 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of progress bar*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * label; /*Pointer to the label on the progress bar*/
|
||||
uint16_t act_value; /*Current value of the progress bar*/
|
||||
uint16_t min_value; /*Minimum value of the progress bar*/
|
||||
uint16_t max_value; /*Maximum value of the progress bar*/
|
||||
char * format_str; /*Format string of the label. E.g. "Progress: %d"*/
|
||||
}lv_pb_ext_t;
|
||||
|
||||
/*Style of progress bar*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rects_t bg;
|
||||
lv_rects_t bar;
|
||||
lv_labels_t label;
|
||||
lv_rects_t bg; /*Style of the background (inherited)*/
|
||||
lv_rects_t bar; /*Style of the bar*/
|
||||
lv_labels_t label; /*Style of the label*/
|
||||
}lv_pbs_t;
|
||||
|
||||
/*Built-in styles of progress bar*/
|
||||
@ -47,28 +59,62 @@ typedef enum
|
||||
LV_PBS_DEF,
|
||||
}lv_pbs_builtin_t;
|
||||
|
||||
/*Data of progress bar*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * label;
|
||||
uint16_t act_value;
|
||||
uint16_t min_value;
|
||||
uint16_t max_value;
|
||||
char * format_str; /*Format string of the label*/
|
||||
}lv_pb_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a progress bar objects
|
||||
* @param par pointer to an object, it will be the parent of the new progress bar
|
||||
* @param copy pointer to a progress bar object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created progress bar
|
||||
*/
|
||||
lv_obj_t * lv_pb_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_pb_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
void lv_pb_set_value(lv_obj_t * obj, uint16_t value);
|
||||
void lv_pb_set_min_max_value(lv_obj_t * obj, uint16_t min, uint16_t max);
|
||||
void lv_pb_set_format_str(lv_obj_t * obj, const char * format);
|
||||
uint16_t lv_pb_get_value(lv_obj_t * obj);
|
||||
lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy_p);
|
||||
|
||||
/**
|
||||
* Signal function of the progress bar
|
||||
* @param pb pointer to a progress bar object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_pb_signal(lv_obj_t * pb, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a new value on the progress bar
|
||||
* @param pb pointer to a progress bar object
|
||||
* @param value new value
|
||||
*/
|
||||
void lv_pb_set_value(lv_obj_t * pb, uint16_t value);
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of a progress bar
|
||||
* @param pb pointer to he progress bar object
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
*/
|
||||
void lv_pb_set_min_max_value(lv_obj_t * pb, uint16_t min, uint16_t max);
|
||||
|
||||
/**
|
||||
* Set format string for the label of the progress bar
|
||||
* @param pb pointer to progress bar object
|
||||
* @param format a printf-like format string with one number (e.g. "Loading (%d)")
|
||||
*/
|
||||
void lv_pb_set_format_str(lv_obj_t * pb, const char * format);
|
||||
|
||||
/**
|
||||
* Get the value of a progress bar
|
||||
* @param pb pointer to a progress bar object
|
||||
* @return the value of the progress bar
|
||||
*/
|
||||
uint16_t lv_pb_get_value(lv_obj_t * pb);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_pbs_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_pbs_t style
|
||||
*/
|
||||
lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -66,10 +66,10 @@ static lv_rects_t lv_rects_border;
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a label objects
|
||||
* @param par pointer to an object, it will be the parent of the new label
|
||||
* Create a rectangle objects
|
||||
* @param par pointer to an object, it will be the parent of the new rectangle
|
||||
* @param copy pointer to a rectangle object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created label
|
||||
* @return pointer to the created rectangle
|
||||
*/
|
||||
lv_obj_t * lv_rect_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
@ -284,11 +284,15 @@ lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy)
|
||||
*/
|
||||
static bool lv_rect_design(lv_obj_t * rect, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/* Because of the radius it is not sure the area is covered*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/* Because of the radius it is not sure the area is covered
|
||||
* Check the areas where there is no radius*/
|
||||
if(LV_SA(rect, lv_rects_t)->empty != 0) return false;
|
||||
|
||||
uint16_t r = LV_SA(rect, lv_rects_t)->round;
|
||||
|
||||
if(r == LV_RECT_CIRCLE) return false;
|
||||
|
||||
area_t area_tmp;
|
||||
|
||||
/*Check horizontally without radius*/
|
||||
@ -338,9 +342,16 @@ static void lv_rect_draw_light(lv_obj_t * rect, const area_t * mask)
|
||||
|
||||
memcpy(&light_style, style, sizeof(lv_rects_t));
|
||||
|
||||
|
||||
|
||||
|
||||
light_style.empty = 1;
|
||||
light_style.bwidth = light_size;
|
||||
light_style.round = style->round + light_size + 1;
|
||||
light_style.round = style->round;
|
||||
if(light_style.round == LV_RECT_CIRCLE) {
|
||||
light_style.round = MATH_MIN(lv_obj_get_width(rect), lv_obj_get_height(rect));
|
||||
}
|
||||
light_style.round += light_size + 1;
|
||||
light_style.bcolor = style->lcolor;
|
||||
light_style.bopa = 100;
|
||||
|
||||
@ -550,7 +561,7 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
||||
while(child_rs != NULL) {
|
||||
cord_t h_row = 0;
|
||||
cord_t w_row = style->hpad * 2; /*The width is minimum the left-right hpad*/
|
||||
cord_t w_row = style->hpad * 2; /*The width is at least the left-right hpad*/
|
||||
uint32_t obj_num = 0;
|
||||
|
||||
/*Find the row closer object and collect some data*/
|
||||
@ -559,7 +570,7 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
|
||||
if(w_row + lv_obj_get_width(child_rc) > w_obj) break; /*If the next object is already not fit then break*/
|
||||
w_row += lv_obj_get_width(child_rc) + style->opad; /*Add the object width + opad*/
|
||||
h_row = max(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
h_row = MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
obj_num ++;
|
||||
}
|
||||
child_rc = ll_get_prev(&rect->child_ll, child_rc); /*Load the next object*/
|
||||
@ -578,7 +589,7 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
}
|
||||
/*If here is only one object in the row then align it to the left*/
|
||||
else if (obj_num == 1) {
|
||||
lv_obj_align(child_rs, rect, LV_ALIGN_IN_TOP_LEFT, style->hpad, act_y);
|
||||
lv_obj_align(child_rs, rect, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
/* Align the children (from child_rs to child_rc)*/
|
||||
else {
|
||||
@ -659,7 +670,7 @@ static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
* Handle auto fit. Set the size of the object to involve all children.
|
||||
* @param rect pointer to an object which size will be modified
|
||||
*/
|
||||
void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
static void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
{
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
|
||||
@ -686,10 +697,10 @@ void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
|
||||
LL_READ(rect->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = min(new_cords.x1, i->cords.x1);
|
||||
new_cords.y1 = min(new_cords.y1, i->cords.y1);
|
||||
new_cords.x2 = max(new_cords.x2, i->cords.x2);
|
||||
new_cords.y2 = max(new_cords.y2, i->cords.y2);
|
||||
new_cords.x1 = MATH_MIN(new_cords.x1, i->cords.x1);
|
||||
new_cords.y1 = MATH_MIN(new_cords.y1, i->cords.y1);
|
||||
new_cords.x2 = MATH_MAX(new_cords.x2, i->cords.x2);
|
||||
new_cords.y2 = MATH_MAX(new_cords.y2, i->cords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
|
@ -24,6 +24,7 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Layout options*/
|
||||
typedef enum
|
||||
{
|
||||
LV_RECT_LAYOUT_OFF = 0,
|
||||
@ -38,6 +39,16 @@ typedef enum
|
||||
LV_RECT_LAYOUT_GRID, /*Align same-sized object into a grid*/
|
||||
}lv_rect_layout_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t layout :5;
|
||||
uint8_t hfit_en :1;
|
||||
uint8_t vfit_en :1;
|
||||
}lv_rect_ext_t;
|
||||
|
||||
|
||||
/*Style of rectangle*/
|
||||
typedef struct
|
||||
{
|
||||
@ -48,11 +59,11 @@ typedef struct
|
||||
color_t lcolor; /*Light color*/
|
||||
uint16_t bwidth;/*Border width*/
|
||||
uint16_t round; /*Radius on the corners*/
|
||||
cord_t hpad; /*Horizontal padding when horizontal fit is enabled*/
|
||||
cord_t vpad; /*Vertical padding when vertical fit is enabled*/
|
||||
cord_t opad; /*Object padding with fit*/
|
||||
cord_t hpad; /*Horizontal padding. Used by fit and layout.*/
|
||||
cord_t vpad; /*Vertical padding. Used by fit and layout.*/
|
||||
cord_t opad; /*Object padding. Used by fit */
|
||||
cord_t light; /*Light size*/
|
||||
uint8_t bopa; /*Border opacity*/
|
||||
uint8_t bopa; /*Border opacity in percentage of object opacity (0..100)*/
|
||||
uint8_t empty :1; /*1: Do not draw the body of the rectangle*/
|
||||
}lv_rects_t;
|
||||
|
||||
@ -64,29 +75,69 @@ typedef enum
|
||||
LV_RECTS_BORDER,
|
||||
}lv_rects_builtin_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t layout :5;
|
||||
uint8_t hfit_en :1;
|
||||
uint8_t vfit_en :1;
|
||||
}lv_rect_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
/*Create function*/
|
||||
|
||||
/**
|
||||
* Create a rectangle objects
|
||||
* @param par pointer to an object, it will be the parent of the new rectangle
|
||||
* @param copy pointer to a rectangle object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created rectangle
|
||||
*/
|
||||
lv_obj_t * lv_rect_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the rectangle
|
||||
* @param rect pointer to a rectangle object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_rect_signal(lv_obj_t * rect, lv_signal_t sign, void * param);
|
||||
|
||||
void lv_rect_set_fit(lv_obj_t * rect, bool hor_en, bool ver_en);
|
||||
/**
|
||||
* Set the layout on a rectangle
|
||||
* @param rect pointer to a rectangle object
|
||||
* @param layout a layout from 'lv_rect_layout_t'
|
||||
*/
|
||||
void lv_rect_set_layout(lv_obj_t * rect, lv_rect_layout_t layout);
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The rectangle size will be set to involve the children horizontally or vertically.
|
||||
* @param rect pointer to a rectangle object
|
||||
* @param hor_en true: enable the horizontal padding
|
||||
* @param ver_en true: enable the vertical padding
|
||||
*/
|
||||
void lv_rect_set_fit(lv_obj_t * rect, bool hor_en, bool ver_en);
|
||||
|
||||
/**
|
||||
* Get the layout of a rectangle
|
||||
* @param rect pointer to rectangle object
|
||||
* @return the layout from 'lv_rect_layout_t'
|
||||
*/
|
||||
lv_rect_layout_t lv_rect_get_layout(lv_obj_t * rect);
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a rectangle
|
||||
* @param rect pointer to a rectangle object
|
||||
* @return true: horizontal padding is enabled
|
||||
*/
|
||||
bool lv_rect_get_hfit(lv_obj_t * rect);
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a rectangle
|
||||
* @param obj pointer to a rectangle object
|
||||
* @return true: vertical padding is enabled
|
||||
*/
|
||||
bool lv_rect_get_vfit(lv_obj_t * rect);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_rects_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_rects_t style
|
||||
*/
|
||||
lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy);
|
||||
|
||||
/**********************
|
||||
|
@ -17,6 +17,15 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configuration*/
|
||||
#ifndef LV_TA_MAX_LENGTH
|
||||
#define LV_TA_MAX_LENGTH 256
|
||||
#endif
|
||||
|
||||
#ifndef LV_TA_CUR_BLINK_TIME
|
||||
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
|
||||
#endif
|
||||
|
||||
#define LV_TA_DEF_WIDTH (120 * LV_DOWNSCALE)
|
||||
#define LV_TA_DEF_HEIGHT (80 * LV_DOWNSCALE)
|
||||
|
||||
|
113
lv_objx/lv_ta.h
113
lv_objx/lv_ta.h
@ -34,6 +34,17 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of text area*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * label; /*Label of the text area*/
|
||||
cord_t cursor_valid_x; /*Used when stepping up/down in text area. Handled by the library*/
|
||||
uint16_t cursor_pos; /*The current cursor position (0: before 1. letter, 1: before 2. letter etc.)*/
|
||||
uint8_t cur_hide :1; /*Indicates that the cursor is visible now or not*/
|
||||
}lv_ta_ext_t;
|
||||
|
||||
/*Style of text area*/
|
||||
typedef struct
|
||||
{
|
||||
@ -53,38 +64,108 @@ typedef enum
|
||||
LV_TAS_TRANSP,
|
||||
}lv_tas_builtin_t;
|
||||
|
||||
/*Data of text area*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * label;
|
||||
cord_t cursor_valid_x;
|
||||
uint16_t cursor_pos;
|
||||
uint8_t cur_hide :1; /*Indicates that the cursor is visible now or not*/
|
||||
}lv_ta_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param);
|
||||
lv_tas_t * lv_tas_get(lv_tas_builtin_t style, lv_tas_t * copy);
|
||||
|
||||
/**
|
||||
* Create a text area objects
|
||||
* @param par pointer to an object, it will be the parent of the new text area
|
||||
* @param copy pointer to a text area object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created text area
|
||||
*/
|
||||
lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the text area
|
||||
* @param ta pointer to a text area object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Insert a character to the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
* @param c a character
|
||||
*/
|
||||
void lv_ta_add_char(lv_obj_t * ta, char c);
|
||||
|
||||
/**
|
||||
* Insert a text to the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
* @param txt a '\0' terminated string to insert
|
||||
*/
|
||||
void lv_ta_add_text(lv_obj_t * ta, const char * txt);
|
||||
|
||||
/**
|
||||
* Set the text of a text area
|
||||
* @param ta pointer to a text area
|
||||
* @param txt pointer to the text
|
||||
*/
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt);
|
||||
|
||||
/**
|
||||
* Delete a the left character from the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_del(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Set the cursor position
|
||||
* @param obj pointer to a text area object
|
||||
* @param pos the new cursor position in character index
|
||||
* < 0 : index from the end of the text
|
||||
* LV_TA_CUR_LAST: go after the last character
|
||||
*/
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
|
||||
void lv_ta_cursor_right (lv_obj_t * ta);
|
||||
void lv_ta_cursor_left(lv_obj_t * taj);
|
||||
|
||||
/**
|
||||
* Move the cursor one character right
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_right(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Move the cursor one character left
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_left(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Move the cursor one line down
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_down(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Move the cursor one line up
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_up(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the text of the i the text area
|
||||
* @param ta obj pointer to a text area object
|
||||
* @return pointer to the text
|
||||
*/
|
||||
const char * lv_ta_get_txt(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the current cursor position in character index
|
||||
* @param ta pointer to a text area object
|
||||
* @return the cursor position
|
||||
*/
|
||||
uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_tas_builtin_t enum
|
||||
* @param copy copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_tas_t style
|
||||
*/
|
||||
lv_tas_t * lv_tas_get(lv_tas_builtin_t style, lv_tas_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -48,10 +48,7 @@ static lv_wins_t lv_wins_def;
|
||||
/**
|
||||
* Create a window objects
|
||||
* @param par pointer to an object, it will be the parent of the new window
|
||||
* @param copy pointer to a window object, if not NULL then
|
||||
lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action);
|
||||
lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action);
|
||||
lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action);the new object will be copied from it
|
||||
* @param copy pointer to a window object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created window
|
||||
*/
|
||||
lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
101
lv_objx/lv_win.h
101
lv_objx/lv_win.h
@ -52,21 +52,31 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of window*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * header; /*Pointer to the header rectangle of the window*/
|
||||
lv_obj_t * title; /*Pointer to the title label of the window*/
|
||||
lv_obj_t * ctrl_holder; /*Pointer to the control button holder rectangle of the window*/
|
||||
}lv_win_ext_t;
|
||||
|
||||
/*Style of window*/
|
||||
typedef struct
|
||||
{
|
||||
lv_pages_t pages; /*Style of ancestor*/
|
||||
/*New style element for this type */
|
||||
/*Header settings*/
|
||||
lv_rects_t header;
|
||||
lv_labels_t title;
|
||||
lv_rects_t ctrl_holder;
|
||||
lv_btns_t ctrl_btn;
|
||||
lv_imgs_t ctrl_img;
|
||||
cord_t ctrl_btn_w;
|
||||
cord_t ctrl_btn_h;
|
||||
opa_t ctrl_btn_opa;
|
||||
opa_t header_opa;
|
||||
lv_rects_t header; /*Style of the header rectangle*/
|
||||
lv_labels_t title; /*Style of the window title*/
|
||||
lv_rects_t ctrl_holder; /*Style of holder of the control buttons*/
|
||||
lv_btns_t ctrl_btn; /*Style of the control buttons*/
|
||||
lv_imgs_t ctrl_img; /*Style of the image on the control buttons*/
|
||||
cord_t ctrl_btn_w; /*Width of the control buttons*/
|
||||
cord_t ctrl_btn_h; /*Height of the control buttons*/
|
||||
opa_t ctrl_btn_opa; /*Width of the control buttons in the percentage of object opacity (0..100)*/
|
||||
opa_t header_opa; /*Opacity of the header in the percentage of object opacity (0..100)*/
|
||||
}lv_wins_t;
|
||||
|
||||
/*Built-in styles of window*/
|
||||
@ -75,29 +85,74 @@ typedef enum
|
||||
LV_WINS_DEF,
|
||||
}lv_wins_builtin_t;
|
||||
|
||||
/*Data of window*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * header;
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * ctrl_holder;
|
||||
}lv_win_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param);
|
||||
lv_wins_t * lv_wins_get(lv_wins_builtin_t style, lv_wins_t * copy);
|
||||
|
||||
lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img, lv_action_t rel_action);
|
||||
/**
|
||||
* Create a window objects
|
||||
* @param par pointer to an object, it will be the parent of the new window
|
||||
* @param copy pointer to a window object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created window
|
||||
*/
|
||||
lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the window
|
||||
* @param win pointer to a window object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_path path of an image on the control button
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img_path, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* A release action which can be assigned to a window control button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always false because the button is deleted with the window
|
||||
*/
|
||||
bool lv_win_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Set the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @param title string of the new title
|
||||
*/
|
||||
void lv_win_set_title(lv_obj_t * win, const char * title);
|
||||
|
||||
/**
|
||||
* Get the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @return title string of the window
|
||||
*/
|
||||
const char * lv_win_get_title(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get the pointer of a widow from one of its control button.
|
||||
* It is useful in the action of the control buttons where only button is known.
|
||||
* @param ctrl_btn pointer to a control button of a window
|
||||
* @return pointer to the window of 'ctrl_btn'
|
||||
*/
|
||||
lv_obj_t * lv_win_get_from_ctrl_btn(lv_obj_t * ctrl_btn);
|
||||
|
||||
/**
|
||||
* Return with a pointer to a built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_wins_builtin_t enum
|
||||
* @param copy_p copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_wins_t style
|
||||
*/
|
||||
lv_wins_t * lv_wins_get(lv_wins_builtin_t style, lv_wins_t * copy);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
24
lvgl.h
24
lvgl.h
@ -9,6 +9,25 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*Test misc. module version*/
|
||||
#include "misc/misc.h"
|
||||
#define LV_MISC_REQ_MAJOR 3
|
||||
#define LV_MISC_REQ_MINOR 0
|
||||
#define LV_MISC_REQ_PATCH 0
|
||||
|
||||
#if MISC_VERSION_MAJOR != LV_MISC_REQ_MAJOR /*The version major has to match*/
|
||||
#error "LV: incompatible misc. module version! See lvgl.h"
|
||||
#endif
|
||||
|
||||
#if MISC_VERSION_MINOR < LV_MISC_REQ_MINOR /*The version minor has to be the same or greater*/
|
||||
#error "LV: incompatible misc. module version! See lvgl.h"
|
||||
#endif
|
||||
|
||||
#if MISC_VERSION_PATCH < LV_MISC_REQ_PATCH /*The version patch has to be the same or greater*/
|
||||
#error "LV: incompatible misc. module version! See lvgl.h"
|
||||
#endif
|
||||
|
||||
#include <lvgl/lv_objx/lv_chart.h>
|
||||
#include "lv_obj/lv_obj.h"
|
||||
#include "lv_objx/lv_btn.h"
|
||||
@ -25,6 +44,7 @@
|
||||
#include "lv_objx/lv_ta.h"
|
||||
#include "lv_objx/lv_win.h"
|
||||
#include "lv_objx/lv_mbox.h"
|
||||
#include "lv_objx/lv_gauge.h"
|
||||
|
||||
#include "lv_app/lv_app.h"
|
||||
|
||||
@ -32,8 +52,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LVGL_VERSION_MAJOR 2
|
||||
#define LVGL_VERSION_MINOR 1
|
||||
#define LVGL_VERSION_PATH 1
|
||||
#define LVGL_VERSION_MINOR 2
|
||||
#define LVGL_VERSION_PATH 0
|
||||
|
||||
|
||||
/**********************
|
||||
|
Loading…
x
Reference in New Issue
Block a user