lv_lmeter: added
This commit is contained in:
@@ -1049,7 +1049,7 @@ static void lv_draw_cont_shadow(const area_t * cords_p, const area_t * mask_p, c
|
|||||||
{
|
{
|
||||||
cord_t swidth = style->swidth;
|
cord_t swidth = style->swidth;
|
||||||
if(swidth == 0) return;
|
if(swidth == 0) return;
|
||||||
uint8_t res = LV_DOWNSCALE * 2;
|
uint8_t res = LV_DOWNSCALE * 1;
|
||||||
if(swidth < res) return;
|
if(swidth < res) return;
|
||||||
|
|
||||||
area_t shadow_area;
|
area_t shadow_area;
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
|||||||
lv_style_t * style = lv_obj_get_style(obj);
|
lv_style_t * style = lv_obj_get_style(obj);
|
||||||
if(style->opa != OPA_TRANSP) {
|
if(style->opa != OPA_TRANSP) {
|
||||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||||
/* tick_wait_ms(100); */ /*DEBUG: Wait after every object draw to see the order of drawing*/
|
//tick_wait_ms(100); /*DEBUG: Wait after every object draw to see the order of drawing*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/
|
/*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/
|
||||||
|
|||||||
@@ -67,15 +67,15 @@ void lv_style_init (void)
|
|||||||
lv_style_set_radius(&lv_style_scr, 0);
|
lv_style_set_radius(&lv_style_scr, 0);
|
||||||
lv_style_set_bwidth(&lv_style_scr, 0);
|
lv_style_set_bwidth(&lv_style_scr, 0);
|
||||||
lv_style_set_swidth(&lv_style_scr, 0);
|
lv_style_set_swidth(&lv_style_scr, 0);
|
||||||
lv_style_set_vpad(&lv_style_scr, LV_DPI / 8);
|
lv_style_set_vpad(&lv_style_scr, LV_DPI / 12);
|
||||||
lv_style_set_hpad(&lv_style_scr, LV_DPI / 8);
|
lv_style_set_hpad(&lv_style_scr, LV_DPI / 12);
|
||||||
lv_style_set_opad(&lv_style_scr, LV_DPI / 8);
|
lv_style_set_opad(&lv_style_scr, LV_DPI / 12);
|
||||||
lv_style_set_bopa(&lv_style_scr, OPA_COVER);
|
lv_style_set_bopa(&lv_style_scr, OPA_COVER);
|
||||||
lv_style_set_empty(&lv_style_scr, false);
|
lv_style_set_empty(&lv_style_scr, false);
|
||||||
|
|
||||||
lv_style_set_font(&lv_style_scr, font_get(FONT_DEFAULT));
|
lv_style_set_font(&lv_style_scr, font_get(FONT_DEFAULT));
|
||||||
lv_style_set_letter_space(&lv_style_scr, 1 * LV_DOWNSCALE);
|
lv_style_set_letter_space(&lv_style_scr, 1 * LV_DOWNSCALE);
|
||||||
lv_style_set_line_space(&lv_style_scr, 2 * LV_DOWNSCALE);
|
lv_style_set_line_space(&lv_style_scr, 3 * LV_DOWNSCALE);
|
||||||
lv_style_set_txt_align(&lv_style_scr, 0);
|
lv_style_set_txt_align(&lv_style_scr, 0);
|
||||||
|
|
||||||
lv_style_set_img_recolor(&lv_style_scr, OPA_TRANSP);
|
lv_style_set_img_recolor(&lv_style_scr, OPA_TRANSP);
|
||||||
@@ -98,14 +98,14 @@ void lv_style_init (void)
|
|||||||
lv_style_set_gcolor(&lv_style_pretty, COLOR_SILVER);
|
lv_style_set_gcolor(&lv_style_pretty, COLOR_SILVER);
|
||||||
lv_style_set_bcolor(&lv_style_pretty, COLOR_MAKE(0x40, 0x40, 0x40));
|
lv_style_set_bcolor(&lv_style_pretty, COLOR_MAKE(0x40, 0x40, 0x40));
|
||||||
lv_style_set_radius(&lv_style_pretty, LV_DPI / 10);
|
lv_style_set_radius(&lv_style_pretty, LV_DPI / 10);
|
||||||
lv_style_set_bwidth(&lv_style_pretty, LV_DPI / 30 >= 1 ? LV_DPI / 30 : 1);
|
lv_style_set_bwidth(&lv_style_pretty, LV_DPI / 40 >= 1 ? LV_DPI / 40 : 1);
|
||||||
lv_style_set_bopa(&lv_style_pretty, OPA_50);
|
lv_style_set_bopa(&lv_style_pretty, OPA_50);
|
||||||
|
|
||||||
/*Pretty color style*/
|
/*Pretty color style*/
|
||||||
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));
|
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));
|
||||||
lv_style_set_ccolor(&lv_style_pretty_color, COLOR_MAKE(0xe0, 0xe0, 0xe0));
|
lv_style_set_ccolor(&lv_style_pretty_color, COLOR_MAKE(0xe0, 0xe0, 0xe0));
|
||||||
|
lv_style_set_mcolor(&lv_style_pretty_color, COLOR_MAKE(0x6b, 0x9a, 0xc7));
|
||||||
lv_style_set_gcolor(&lv_style_pretty_color, COLOR_MAKE(0x2b, 0x59, 0x8b));
|
lv_style_set_gcolor(&lv_style_pretty_color, COLOR_MAKE(0x2b, 0x59, 0x8b));
|
||||||
lv_style_set_mcolor(&lv_style_pretty_color, COLOR_MAKE(0x90, 0xb3, 0xd5));
|
|
||||||
lv_style_set_bcolor(&lv_style_pretty_color, COLOR_MAKE(0x15, 0x2c, 0x42));
|
lv_style_set_bcolor(&lv_style_pretty_color, COLOR_MAKE(0x15, 0x2c, 0x42));
|
||||||
lv_style_set_scolor(&lv_style_pretty_color, COLOR_MAKE(0x6a, 0x8f, 0xb4));
|
lv_style_set_scolor(&lv_style_pretty_color, COLOR_MAKE(0x6a, 0x8f, 0xb4));
|
||||||
lv_style_set_swidth(&lv_style_pretty_color, 0);
|
lv_style_set_swidth(&lv_style_pretty_color, 0);
|
||||||
@@ -126,14 +126,14 @@ void lv_style_init (void)
|
|||||||
lv_style_set_gcolor(&lv_style_btn_rel, COLOR_MAKE(0x19, 0x3a, 0x5d));
|
lv_style_set_gcolor(&lv_style_btn_rel, COLOR_MAKE(0x19, 0x3a, 0x5d));
|
||||||
lv_style_set_bcolor(&lv_style_btn_rel, COLOR_MAKE(0x0b, 0x19, 0x28));
|
lv_style_set_bcolor(&lv_style_btn_rel, COLOR_MAKE(0x0b, 0x19, 0x28));
|
||||||
lv_style_set_ccolor(&lv_style_btn_rel, COLOR_MAKE(0xff, 0xff, 0xff));
|
lv_style_set_ccolor(&lv_style_btn_rel, COLOR_MAKE(0xff, 0xff, 0xff));
|
||||||
lv_style_set_bwidth(&lv_style_btn_rel, LV_DPI / 30 >= 1 ? LV_DPI / 30 : 1);
|
lv_style_set_bwidth(&lv_style_btn_rel, LV_DPI / 40 >= 1 ? LV_DPI / 40 : 1);
|
||||||
lv_style_set_radius(&lv_style_btn_rel, LV_DPI / 10);
|
lv_style_set_radius(&lv_style_btn_rel, LV_DPI / 10);
|
||||||
lv_style_set_bopa(&lv_style_btn_rel, OPA_70);
|
lv_style_set_bopa(&lv_style_btn_rel, OPA_70);
|
||||||
lv_style_set_scolor(&lv_style_btn_rel, COLOR_GRAY);
|
lv_style_set_scolor(&lv_style_btn_rel, COLOR_GRAY);
|
||||||
lv_style_set_swidth(&lv_style_btn_rel, 0);
|
lv_style_set_swidth(&lv_style_btn_rel, 0);
|
||||||
lv_style_set_hpad(&lv_style_btn_rel, LV_DPI / 3);
|
lv_style_set_hpad(&lv_style_btn_rel, LV_DPI / 4);
|
||||||
lv_style_set_vpad(&lv_style_btn_rel, LV_DPI / 4);
|
lv_style_set_vpad(&lv_style_btn_rel, LV_DPI / 6);
|
||||||
lv_style_set_opad(&lv_style_btn_rel, LV_DPI / 6);
|
lv_style_set_opad(&lv_style_btn_rel, LV_DPI / 10);
|
||||||
|
|
||||||
/*Button pressed style*/
|
/*Button pressed style*/
|
||||||
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));
|
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||||
@@ -143,21 +143,21 @@ void lv_style_init (void)
|
|||||||
|
|
||||||
/*Button toggle released style*/
|
/*Button toggle released style*/
|
||||||
memcpy(&lv_style_btn_trel, &lv_style_btn_rel, sizeof(lv_style_t));
|
memcpy(&lv_style_btn_trel, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||||
lv_style_set_gcolor(&lv_style_btn_trel, COLOR_MAKE(0x37, 0x62, 0x90));
|
|
||||||
lv_style_set_mcolor(&lv_style_btn_trel, COLOR_MAKE(0x0a, 0x11, 0x22));
|
lv_style_set_mcolor(&lv_style_btn_trel, COLOR_MAKE(0x0a, 0x11, 0x22));
|
||||||
|
lv_style_set_gcolor(&lv_style_btn_trel, COLOR_MAKE(0x37, 0x62, 0x90));
|
||||||
lv_style_set_bcolor(&lv_style_btn_trel, COLOR_MAKE(0x01, 0x07, 0x0d));
|
lv_style_set_bcolor(&lv_style_btn_trel, COLOR_MAKE(0x01, 0x07, 0x0d));
|
||||||
lv_style_set_ccolor(&lv_style_btn_trel, COLOR_MAKE(0xc8, 0xdd, 0xf4));
|
lv_style_set_ccolor(&lv_style_btn_trel, COLOR_MAKE(0xc8, 0xdd, 0xf4));
|
||||||
|
|
||||||
/*Button toggle pressed style*/
|
/*Button toggle pressed style*/
|
||||||
memcpy(&lv_style_btn_tpr, &lv_style_btn_rel, sizeof(lv_style_t));
|
memcpy(&lv_style_btn_tpr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||||
lv_style_set_gcolor(&lv_style_btn_tpr, COLOR_MAKE(0x2b, 0x4c, 0x70));
|
|
||||||
lv_style_set_mcolor(&lv_style_btn_tpr, COLOR_MAKE(0x02, 0x14, 0x27));
|
lv_style_set_mcolor(&lv_style_btn_tpr, COLOR_MAKE(0x02, 0x14, 0x27));
|
||||||
|
lv_style_set_gcolor(&lv_style_btn_tpr, COLOR_MAKE(0x2b, 0x4c, 0x70));
|
||||||
lv_style_set_ccolor(&lv_style_btn_tpr, COLOR_MAKE(0xa4, 0xb5, 0xc6));
|
lv_style_set_ccolor(&lv_style_btn_tpr, COLOR_MAKE(0xa4, 0xb5, 0xc6));
|
||||||
|
|
||||||
/*Button inactive style*/
|
/*Button inactive style*/
|
||||||
memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t));
|
memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||||
lv_style_set_gcolor(&lv_style_btn_ina, COLOR_MAKE(0xd8, 0xd8, 0xd8));
|
|
||||||
lv_style_set_mcolor(&lv_style_btn_ina, COLOR_MAKE(0xd8, 0xd8, 0xd8));
|
lv_style_set_mcolor(&lv_style_btn_ina, COLOR_MAKE(0xd8, 0xd8, 0xd8));
|
||||||
|
lv_style_set_gcolor(&lv_style_btn_ina, COLOR_MAKE(0xd8, 0xd8, 0xd8));
|
||||||
lv_style_set_bcolor(&lv_style_btn_ina, COLOR_MAKE(0x90, 0x90, 0x90));
|
lv_style_set_bcolor(&lv_style_btn_ina, COLOR_MAKE(0x90, 0x90, 0x90));
|
||||||
lv_style_set_ccolor(&lv_style_btn_ina, COLOR_MAKE(0x70, 0x70, 0x70));
|
lv_style_set_ccolor(&lv_style_btn_ina, COLOR_MAKE(0x70, 0x70, 0x70));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,6 +469,7 @@ static void lv_btnm_create_btns(lv_obj_t * btnm, const char ** map)
|
|||||||
|
|
||||||
if(ext->btn_areas != NULL) {
|
if(ext->btn_areas != NULL) {
|
||||||
dm_free(ext->btn_areas);
|
dm_free(ext->btn_areas);
|
||||||
|
ext->btn_areas = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ext->btn_areas = dm_alloc(sizeof(area_t) * btn_cnt);
|
ext->btn_areas = dm_alloc(sizeof(area_t) * btn_cnt);
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#define LV_GAUGE_DEF_WIDTH (3 * LV_DPI)
|
|
||||||
#define LV_GAUGE_DEF_HEIGHT (3 * LV_DPI)
|
|
||||||
#define LV_GAUGE_DEF_NEEDLE_COLOR COLOR_RED
|
#define LV_GAUGE_DEF_NEEDLE_COLOR COLOR_RED
|
||||||
#define LV_GAUGE_DEF_ANGLE 220
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -63,7 +60,7 @@ static lv_design_f_t ancestor_design_f = NULL;
|
|||||||
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||||
{
|
{
|
||||||
/*Create the ancestor gauge*/
|
/*Create the ancestor gauge*/
|
||||||
lv_obj_t * new_gauge = lv_cont_create(par, copy);
|
lv_obj_t * new_gauge = lv_lmeter_create(par, copy);
|
||||||
dm_assert(new_gauge);
|
dm_assert(new_gauge);
|
||||||
|
|
||||||
/*Allocate the gauge type specific extended data*/
|
/*Allocate the gauge type specific extended data*/
|
||||||
@@ -71,14 +68,10 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
|||||||
dm_assert(ext);
|
dm_assert(ext);
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
ext->min = 0;
|
|
||||||
ext->max = 100;
|
|
||||||
ext->needle_num = 0;
|
ext->needle_num = 0;
|
||||||
ext->values = NULL;
|
ext->values = NULL;
|
||||||
ext->needle_color = NULL;
|
ext->needle_colors = NULL;
|
||||||
ext->low_critical = 0;
|
ext->low_critical = 0;
|
||||||
ext->scale_angle = LV_GAUGE_DEF_ANGLE;
|
|
||||||
ext->scale_label_num = 6;
|
|
||||||
ext->style_critical = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
ext->style_critical = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||||
|
|
||||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_gauge);
|
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_gauge);
|
||||||
@@ -89,17 +82,17 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Init the new gauge gauge*/
|
/*Init the new gauge gauge*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
|
lv_lmeter_set_scale(new_gauge, 220, 6);
|
||||||
lv_gauge_set_needle_num(new_gauge, 1, NULL);
|
lv_gauge_set_needle_num(new_gauge, 1, NULL);
|
||||||
lv_obj_set_size(new_gauge, LV_GAUGE_DEF_WIDTH, LV_GAUGE_DEF_HEIGHT);
|
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
||||||
lv_obj_set_style(new_gauge, lv_style_get(LV_STYLE_PRETTY, NULL));
|
lv_obj_set_style(new_gauge, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||||
}
|
}
|
||||||
/*Copy an existing gauge*/
|
/*Copy an existing gauge*/
|
||||||
else {
|
else {
|
||||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext(copy);
|
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;
|
ext->low_critical = copy_ext->low_critical;
|
||||||
lv_gauge_set_needle_num(new_gauge, copy_ext->needle_num, copy_ext->needle_color);
|
lv_gauge_set_style_critical(new_gauge, lv_gauge_get_style_critical(copy));
|
||||||
|
lv_gauge_set_needle_num(new_gauge, copy_ext->needle_num, copy_ext->needle_colors);
|
||||||
|
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
for(i = 0; i < ext->needle_num; i++) {
|
for(i = 0; i < ext->needle_num; i++) {
|
||||||
@@ -125,7 +118,7 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
|||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
valid = lv_cont_signal(gauge, sign, param);
|
valid = lv_lmeter_signal(gauge, sign, param);
|
||||||
|
|
||||||
/* The object can be deleted so check its validity and then
|
/* The object can be deleted so check its validity and then
|
||||||
* make the object specific signal handling */
|
* make the object specific signal handling */
|
||||||
@@ -136,7 +129,7 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
|||||||
ext->values = NULL;
|
ext->values = NULL;
|
||||||
}
|
}
|
||||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||||
lv_style_t * style_crit = lv_gauge_get_style_crit(gauge);
|
lv_style_t * style_crit = lv_gauge_get_style_critical(gauge);
|
||||||
if(style_crit->swidth > gauge->ext_size) gauge->ext_size = style_crit->swidth;
|
if(style_crit->swidth > gauge->ext_size) gauge->ext_size = style_crit->swidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,36 +150,24 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
|||||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors)
|
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors)
|
||||||
{
|
{
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||||
if(ext->values != NULL) dm_free(ext->values);
|
if(ext->values != NULL) {
|
||||||
|
dm_free(ext->values);
|
||||||
|
ext->values = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ext->values = dm_realloc(ext->values, num * sizeof(int16_t));
|
ext->values = dm_realloc(ext->values, num * sizeof(int16_t));
|
||||||
|
|
||||||
|
int16_t min = lv_bar_get_min_value(gauge);
|
||||||
uint8_t n;
|
uint8_t n;
|
||||||
for(n = ext->needle_num; n < num; n++) {
|
for(n = ext->needle_num; n < num; n++) {
|
||||||
ext->values[n] = ext->min;
|
ext->values[n] = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
ext->needle_num = num;
|
ext->needle_num = num;
|
||||||
ext->needle_color = colors;
|
ext->needle_colors = colors;
|
||||||
lv_obj_inv(gauge);
|
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
|
* Set the value of a needle
|
||||||
@@ -200,8 +181,11 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value)
|
|||||||
|
|
||||||
if(needle >= ext->needle_num) return;
|
if(needle >= ext->needle_num) return;
|
||||||
|
|
||||||
if(value > ext->max) value = ext->max;
|
int16_t min = lv_bar_get_min_value(gauge);
|
||||||
if(value < ext->min) value = ext->min;
|
int16_t max = lv_bar_get_max_value(gauge);
|
||||||
|
|
||||||
|
if(value > max) value = max;
|
||||||
|
else if(value < min) value = min;
|
||||||
|
|
||||||
ext->values[needle] = value;
|
ext->values[needle] = value;
|
||||||
|
|
||||||
@@ -222,21 +206,6 @@ void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low)
|
|||||||
lv_obj_inv(gauge);
|
lv_obj_inv(gauge);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the scale settings of a gauge
|
|
||||||
* @param gauge pointer to a gauge object
|
|
||||||
* @param angle angle of the scale (0..360)
|
|
||||||
* @param label_num number of labels on the scale (~5)
|
|
||||||
*/
|
|
||||||
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t label_num)
|
|
||||||
{
|
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
|
||||||
ext->scale_angle = angle;
|
|
||||||
ext->scale_label_num = label_num;
|
|
||||||
|
|
||||||
lv_obj_inv(gauge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the critical style of the gauge
|
* Set the critical style of the gauge
|
||||||
* @param gauge pointer to a gauge object
|
* @param gauge pointer to a gauge object
|
||||||
@@ -274,8 +243,9 @@ uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge)
|
|||||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle)
|
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle)
|
||||||
{
|
{
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||||
|
int16_t min = lv_bar_get_min_value(gauge);
|
||||||
|
|
||||||
if(needle >= ext->needle_num) return ext->min;
|
if(needle >= ext->needle_num) return min;
|
||||||
|
|
||||||
return ext->values[needle];
|
return ext->values[needle];
|
||||||
}
|
}
|
||||||
@@ -297,7 +267,7 @@ bool lv_gauge_get_low_critical(lv_obj_t * gauge)
|
|||||||
* @param gauge pointer to a gauge object
|
* @param gauge pointer to a gauge object
|
||||||
* @return pointer to the critical style
|
* @return pointer to the critical style
|
||||||
*/
|
*/
|
||||||
lv_style_t * lv_gauge_get_style_crit(lv_obj_t * gauge)
|
lv_style_t * lv_gauge_get_style_critical(lv_obj_t * gauge)
|
||||||
{
|
{
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||||
|
|
||||||
@@ -322,28 +292,31 @@ lv_style_t * lv_gauge_get_style_crit(lv_obj_t * gauge)
|
|||||||
*/
|
*/
|
||||||
static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mode_t 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*/
|
/*Return false if the object is not covers the mask_p area*/
|
||||||
if(mode == LV_DESIGN_COVER_CHK) {
|
if(mode == LV_DESIGN_COVER_CHK) {
|
||||||
return ancestor_design_f(gauge, mask, mode);
|
return false;
|
||||||
}
|
}
|
||||||
/*Draw the object*/
|
/*Draw the object*/
|
||||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||||
lv_style_t * style_base = lv_obj_get_style(gauge);
|
lv_style_t * style_base = lv_obj_get_style(gauge);
|
||||||
lv_style_t * style_critical = lv_gauge_get_style_crit(gauge);
|
lv_style_t * style_critical = lv_gauge_get_style_critical(gauge);
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||||
|
|
||||||
/* Draw the background
|
/* Draw the background
|
||||||
* Re-color the gauge according to the critical value*/
|
* Re-color the gauge according to the critical value*/
|
||||||
lv_style_t style_bg;
|
lv_style_t style_bg;
|
||||||
|
int16_t min = lv_bar_get_min_value(gauge);
|
||||||
|
int16_t max = lv_bar_get_max_value(gauge);
|
||||||
|
|
||||||
int16_t critical_val = ext->low_critical == 0 ? ext->min : ext->max;
|
int16_t critical_val = ext->low_critical == 0 ? min : max;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
for(i = 0; i < ext->needle_num; 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]);
|
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);
|
opa_t ratio = ((critical_val - min) * OPA_COVER) / (max - min);
|
||||||
|
|
||||||
if(ext->low_critical != 0) ratio = OPA_COVER - ratio;
|
if(ext->low_critical != 0) ratio = OPA_COVER - ratio;
|
||||||
|
|
||||||
@@ -356,9 +329,7 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod
|
|||||||
style_bg.scolor = color_mix(style_critical->scolor, style_base->scolor, ratio);
|
style_bg.scolor = color_mix(style_critical->scolor, style_base->scolor, ratio);
|
||||||
style_bg.swidth = (cord_t)((cord_t)(style_critical->swidth + style_base->swidth) * ratio) >> 8;
|
style_bg.swidth = (cord_t)((cord_t)(style_critical->swidth + style_base->swidth) * ratio) >> 8;
|
||||||
|
|
||||||
gauge->style_p = &style_bg;
|
lv_draw_rect(&gauge->cords, mask, &style_bg);
|
||||||
ancestor_design_f(gauge, mask, mode);
|
|
||||||
gauge->style_p = style_base;
|
|
||||||
|
|
||||||
lv_gauge_draw_scale(gauge, mask, &style_bg);
|
lv_gauge_draw_scale(gauge, mask, &style_bg);
|
||||||
|
|
||||||
@@ -379,19 +350,21 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod
|
|||||||
*/
|
*/
|
||||||
static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_t * style)
|
static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_t * style)
|
||||||
{
|
{
|
||||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
|
||||||
|
|
||||||
char scale_txt[16];
|
char scale_txt[16];
|
||||||
|
|
||||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->hpad;
|
cord_t r = lv_obj_get_width(gauge) / 2 - style->hpad;
|
||||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
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;
|
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
int16_t scale_angle = lv_lmeter_get_scale_angle(gauge);
|
||||||
|
uint16_t scale_num = lv_lmeter_get_scale_num(gauge);
|
||||||
|
int16_t angle_ofs = 90 + (360 - scale_angle) / 2;
|
||||||
|
int16_t min = lv_bar_get_min_value(gauge);
|
||||||
|
int16_t max = lv_bar_get_max_value(gauge);
|
||||||
|
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
for(i = 0; i < ext->scale_label_num; i++) {
|
for(i = 0; i < scale_num; i++) {
|
||||||
/*Calculate the position a scale label*/
|
/*Calculate the position a scale label*/
|
||||||
int16_t angle = (i * ext->scale_angle) / (ext->scale_label_num - 1) + angle_ofs;
|
int16_t angle = (i * scale_angle) / (scale_num - 1) + angle_ofs;
|
||||||
|
|
||||||
cord_t y = (int32_t)((int32_t)trigo_sin(angle) * r) / TRIGO_SIN_MAX;
|
cord_t y = (int32_t)((int32_t)trigo_sin(angle) * r) / TRIGO_SIN_MAX;
|
||||||
y += y_ofs;
|
y += y_ofs;
|
||||||
@@ -399,8 +372,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_
|
|||||||
cord_t x = (int32_t)((int32_t)trigo_sin(angle + 90) * r) / TRIGO_SIN_MAX;
|
cord_t x = (int32_t)((int32_t)trigo_sin(angle + 90) * r) / TRIGO_SIN_MAX;
|
||||||
x += x_ofs;
|
x += x_ofs;
|
||||||
|
|
||||||
int16_t scale_act = (int32_t)((int32_t)(ext->max - ext->min) * i) / (ext->scale_label_num - 1);
|
int16_t scale_act = (int32_t)((int32_t)(max - min) * i) / (scale_num - 1);
|
||||||
scale_act += ext->min;
|
scale_act += min;
|
||||||
sprintf(scale_txt, "%d", scale_act);
|
sprintf(scale_txt, "%d", scale_act);
|
||||||
|
|
||||||
area_t label_cord;
|
area_t label_cord;
|
||||||
@@ -431,7 +404,10 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style
|
|||||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->opad;
|
cord_t r = lv_obj_get_width(gauge) / 2 - style->opad;
|
||||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
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;
|
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
uint16_t angle = lv_lmeter_get_scale_angle(gauge);
|
||||||
|
int16_t angle_ofs = 90 + (360 - angle) / 2;
|
||||||
|
int16_t min = lv_bar_get_min_value(gauge);
|
||||||
|
int16_t max = lv_bar_get_max_value(gauge);
|
||||||
point_t p_mid;
|
point_t p_mid;
|
||||||
point_t p_end;
|
point_t p_end;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
@@ -442,14 +418,13 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style
|
|||||||
p_mid.y = y_ofs;
|
p_mid.y = y_ofs;
|
||||||
for(i = 0; i < ext->needle_num; i++) {
|
for(i = 0; i < ext->needle_num; i++) {
|
||||||
/*Calculate the end point of a needle*/
|
/*Calculate the end point of a needle*/
|
||||||
int16_t needle_angle = (ext->values[i] - ext->min) * ext->scale_angle /
|
int16_t needle_angle = (ext->values[i] - min) * angle / (max - min) + angle_ofs;
|
||||||
(ext->max - ext->min) + angle_ofs;
|
|
||||||
p_end.y = (trigo_sin(needle_angle) * r) / TRIGO_SIN_MAX + y_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;
|
p_end.x = (trigo_sin(needle_angle + 90) * r) / TRIGO_SIN_MAX + x_ofs;
|
||||||
|
|
||||||
/*Draw the needle with the corresponding color*/
|
/*Draw the needle with the corresponding color*/
|
||||||
if(ext->needle_color == NULL) style_needle.ccolor = LV_GAUGE_DEF_NEEDLE_COLOR;
|
if(ext->needle_colors == NULL) style_needle.ccolor = LV_GAUGE_DEF_NEEDLE_COLOR;
|
||||||
else style_needle.ccolor = ext->needle_color[i];
|
else style_needle.ccolor = ext->needle_colors[i];
|
||||||
|
|
||||||
lv_draw_line(&p_mid, &p_end, mask, &style_needle);
|
lv_draw_line(&p_mid, &p_end, mask, &style_needle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "../lv_obj/lv_obj.h"
|
#include "../lv_obj/lv_obj.h"
|
||||||
#include <lvgl/lv_objx/lv_cont.h>
|
#include "lv_lmeter.h"
|
||||||
#include "lv_label.h"
|
#include "lv_label.h"
|
||||||
#include "lv_line.h"
|
#include "lv_line.h"
|
||||||
|
|
||||||
@@ -48,15 +48,11 @@
|
|||||||
/*Data of gauge*/
|
/*Data of gauge*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/*No inherited ext*/ /*Ext. of ancestor*/
|
lv_lmeter_ext_t lmeter; /*Ext. of ancestor*/
|
||||||
/*New data for this type */
|
/*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) */
|
int16_t * values; /*Array of the set values (for needles) */
|
||||||
lv_style_t * style_critical; /*Fade to this style nearer to the critical value*/
|
lv_style_t * style_critical; /*Fade to this style nearer to the critical value*/
|
||||||
color_t * needle_color; /*A color of the needles (color_t my_colors[needle_num])*/
|
color_t * needle_colors; /*Color of the needles (color_t my_colors[needle_num])*/
|
||||||
uint16_t scale_angle; /*Angle of the scale in deg. (e.g. 220)*/
|
|
||||||
uint8_t scale_label_num; /*Number of scale labels (~6)*/
|
|
||||||
uint8_t needle_num; /*Number of needles*/
|
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*/
|
uint8_t low_critical:1; /*0: the higher value is more critical, 1: the lower value is more critical*/
|
||||||
}lv_gauge_ext_t;
|
}lv_gauge_ext_t;
|
||||||
@@ -83,20 +79,13 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy);
|
|||||||
bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param);
|
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)
|
* Set the number of needles
|
||||||
* @param gauge pointer to gauge object
|
* @param gauge pointer to gauge object
|
||||||
* @param num number of needles
|
* @param num number of needles
|
||||||
|
* @param colors an array of colors for needles (with 'num' elements)
|
||||||
*/
|
*/
|
||||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors);
|
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors);
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Set the value of a needle
|
||||||
* @param gauge pointer to gauge
|
* @param gauge pointer to gauge
|
||||||
@@ -105,14 +94,6 @@ void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max);
|
|||||||
*/
|
*/
|
||||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t 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)
|
* Set which value is more critical (lower or higher)
|
||||||
* @param gauge pointer to a gauge object
|
* @param gauge pointer to a gauge object
|
||||||
@@ -120,7 +101,13 @@ void lv_gauge_set_text(lv_obj_t * gauge, const char * txt);
|
|||||||
*/
|
*/
|
||||||
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low);
|
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low);
|
||||||
|
|
||||||
void lv_gauge_vet_style_critical(lv_obj_t * gauge, lv_style_t * style);
|
/**
|
||||||
|
* Set the critical style of the gauge
|
||||||
|
* @param gauge pointer to a gauge object
|
||||||
|
* @param style pointer to the new critical style
|
||||||
|
*/
|
||||||
|
void lv_gauge_set_style_critical(lv_obj_t * gauge, lv_style_t * style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of needles on a gauge
|
* Get the number of needles on a gauge
|
||||||
* @param gauge pointer to gauge
|
* @param gauge pointer to gauge
|
||||||
@@ -136,13 +123,6 @@ uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge);
|
|||||||
*/
|
*/
|
||||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle);
|
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)
|
* Get which value is more critical (lower or higher)
|
||||||
* @param gauge pointer to a gauge object
|
* @param gauge pointer to a gauge object
|
||||||
@@ -150,7 +130,12 @@ const char * lv_gauge_get_text(lv_obj_t * gauge);
|
|||||||
*/
|
*/
|
||||||
bool lv_gauge_get_low_critical(lv_obj_t * gauge);
|
bool lv_gauge_get_low_critical(lv_obj_t * gauge);
|
||||||
|
|
||||||
lv_style_t * lv_gauge_get_style_crit(lv_obj_t * gauge);
|
/**
|
||||||
|
* Get the critical style of the gauge
|
||||||
|
* @param gauge pointer to a gauge object
|
||||||
|
* @return pointer to the critical style
|
||||||
|
*/
|
||||||
|
lv_style_t * lv_gauge_get_style_critical(lv_obj_t * gauge);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
|||||||
header.w = lv_obj_get_width(img);
|
header.w = lv_obj_get_width(img);
|
||||||
header.h = lv_obj_get_height(img);
|
header.h = lv_obj_get_height(img);
|
||||||
header.transp = 0;
|
header.transp = 0;
|
||||||
|
header.cd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs_close(&file);
|
fs_close(&file);
|
||||||
@@ -193,7 +194,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
|||||||
txt_get_size(&size, fn, style->font, style->letter_space, style->line_space, CORD_MAX, TXT_FLAG_NONE);
|
txt_get_size(&size, fn, style->font, style->letter_space, style->line_space, CORD_MAX, TXT_FLAG_NONE);
|
||||||
ext->w = size.x;
|
ext->w = size.x;
|
||||||
ext->h = size.y;
|
ext->h = size.y;
|
||||||
ext->transp = 0;
|
ext->transp = 1; /*Symbols always have transparent parts*/
|
||||||
#else
|
#else
|
||||||
/*Never goes here, just to be sure handle this */
|
/*Never goes here, just to be sure handle this */
|
||||||
ext->w = lv_obj_get_width(img);
|
ext->w = lv_obj_get_width(img);
|
||||||
@@ -299,12 +300,10 @@ static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t
|
|||||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||||
|
|
||||||
if(mode == LV_DESIGN_COVER_CHK) {
|
if(mode == LV_DESIGN_COVER_CHK) {
|
||||||
if(ext->transp == 0) {
|
bool cover = false;
|
||||||
bool cover;
|
if(ext->transp == 0) cover = area_is_in(mask, &img->cords);
|
||||||
cover = area_is_in(mask, &img->cords);
|
|
||||||
return cover;
|
return cover;
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||||
if(ext->h == 0 || ext->w == 0) return true;
|
if(ext->h == 0 || ext->w == 0) return true;
|
||||||
area_t cords;
|
area_t cords;
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ typedef struct
|
|||||||
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
||||||
/*New data for this type */
|
/*New data for this type */
|
||||||
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
||||||
cord_t w; /*Width of the image (doubled when upscaled)*/
|
cord_t w; /*Width of the image (doubled when upscaled) (Handled by the library)*/
|
||||||
cord_t h; /*Height of the image (doubled when upscaled)*/
|
cord_t h; /*Height of the image (doubled when upscaled) (Handled by the library)*/
|
||||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||||
uint8_t upscale :1; /*1: upscale to double size with antialaissing*/
|
uint8_t upscale :1; /*1: upscale to double size with antialaissing*/
|
||||||
uint8_t transp :1; /*Transp. bit in the image header (Handled by the library)*/
|
uint8_t transp :1; /*Transp. bit in the image header (Handled by the library)*/
|
||||||
@@ -53,21 +53,21 @@ typedef struct
|
|||||||
* the result image converter utility*/
|
* the result image converter utility*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16_t w; /*Width of the image map*/
|
uint32_t w:12; /*Width of the image map*/
|
||||||
uint16_t h; /*Height of the image map*/
|
uint32_t h:12; /*Height of the image map*/
|
||||||
uint16_t cd; /*Color depth (8/16 or 24)*/
|
uint32_t transp:1; /*1: The image contains transparent pixels with LV_COLOR_TRANSP color*/
|
||||||
uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/
|
uint32_t cd:3; /*Color depth (0: reserved, 1: 8 bit, 2: 16 bit or 3: 24 bit, 4-7: reserved)*/
|
||||||
|
uint32_t res :4; /*Reserved*/
|
||||||
}lv_img_raw_header_t;
|
}lv_img_raw_header_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an image objects
|
* Create an image objects
|
||||||
* @param par pointer to an object, it will be the parent of the new button
|
* @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
|
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
|
||||||
* @return pointer to the created image
|
* @return pointer to the created image
|
||||||
*/
|
*/
|
||||||
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
||||||
@@ -105,6 +105,7 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable the upscaling with LV_DOWNSCALE.
|
* 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 img pointer to an image
|
||||||
* @param en true: upscale enable, false: upscale disable
|
* @param en true: upscale enable, false: upscale disable
|
||||||
*/
|
*/
|
||||||
@@ -117,7 +118,6 @@ void lv_img_set_upscale(lv_obj_t * img, bool en);
|
|||||||
*/
|
*/
|
||||||
bool lv_img_get_auto_size(lv_obj_t * img);
|
bool lv_img_get_auto_size(lv_obj_t * img);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the upscale enable attribute
|
* Get the upscale enable attribute
|
||||||
* @param img pointer to an image
|
* @param img pointer to an image
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
|
|||||||
uint32_t len = strlen(text) + 1;
|
uint32_t len = strlen(text) + 1;
|
||||||
if(ext->txt != NULL && ext->static_txt == 0) {
|
if(ext->txt != NULL && ext->static_txt == 0) {
|
||||||
dm_free(ext->txt);
|
dm_free(ext->txt);
|
||||||
|
ext->txt = NULL;
|
||||||
}
|
}
|
||||||
ext->txt = dm_alloc(len);
|
ext->txt = dm_alloc(len);
|
||||||
strcpy(ext->txt, text);
|
strcpy(ext->txt, text);
|
||||||
@@ -200,6 +201,7 @@ void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size
|
|||||||
/*Allocate space for the new text*/
|
/*Allocate space for the new text*/
|
||||||
if(ext->txt != NULL && ext->static_txt == 0) {
|
if(ext->txt != NULL && ext->static_txt == 0) {
|
||||||
dm_free(ext->txt);
|
dm_free(ext->txt);
|
||||||
|
ext->txt = NULL;
|
||||||
}
|
}
|
||||||
ext->txt = dm_alloc(size + 1);
|
ext->txt = dm_alloc(size + 1);
|
||||||
memcpy(ext->txt, array, size);
|
memcpy(ext->txt, array, size);
|
||||||
@@ -220,6 +222,7 @@ void lv_label_set_text_static(lv_obj_t * label, const char * text)
|
|||||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||||
if(ext->static_txt == 0 && ext->txt != NULL) {
|
if(ext->static_txt == 0 && ext->txt != NULL) {
|
||||||
dm_free(ext->txt);
|
dm_free(ext->txt);
|
||||||
|
ext->txt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(text != NULL) {
|
if(text != NULL) {
|
||||||
|
|||||||
242
lv_objx/lv_lmeter.c
Normal file
242
lv_objx/lv_lmeter.c
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_lmeter.c
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*Search an replace: line meter -> object normal name with lower case (e.g. button, label etc.)
|
||||||
|
* lmeter -> object short name with lower case(e.g. btn, label etc)
|
||||||
|
* LMETER -> object short name with upper case (e.g. BTN, LABEL etc.)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
#include "lv_conf.h"
|
||||||
|
#if USE_LV_LMETER != 0
|
||||||
|
|
||||||
|
#include "lv_lmeter.h"
|
||||||
|
#include "misc/math/trigo.h"
|
||||||
|
#include "../lv_draw/lv_draw.h"
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* TYPEDEFS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC PROTOTYPES
|
||||||
|
**********************/
|
||||||
|
static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_mode_t mode);
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC VARIABLES
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* MACROS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* GLOBAL FUNCTIONS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/*-----------------
|
||||||
|
* Create function
|
||||||
|
*-----------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a line meter objects
|
||||||
|
* @param par pointer to an object, it will be the parent of the new line meter
|
||||||
|
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
|
||||||
|
* @return pointer to the created line meter
|
||||||
|
*/
|
||||||
|
lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||||
|
{
|
||||||
|
/*Create the ancestor of line meter*/
|
||||||
|
lv_obj_t * new_lmeter = lv_bar_create(par, copy);
|
||||||
|
dm_assert(new_lmeter);
|
||||||
|
|
||||||
|
/*Allocate the line meter type specific extended data*/
|
||||||
|
lv_lmeter_ext_t * ext = lv_obj_alloc_ext(new_lmeter, sizeof(lv_lmeter_ext_t));
|
||||||
|
dm_assert(ext);
|
||||||
|
|
||||||
|
/*Initialize the allocated 'ext' */
|
||||||
|
ext->scale_num = 31; /*Odd scale number looks better*/
|
||||||
|
ext->scale_angle = 240; /*(scale_num - 1) * N looks better */
|
||||||
|
|
||||||
|
/*The signal and design functions are not copied so set them here*/
|
||||||
|
lv_obj_set_signal_f(new_lmeter, lv_lmeter_signal);
|
||||||
|
lv_obj_set_design_f(new_lmeter, lv_lmeter_design);
|
||||||
|
|
||||||
|
/*Init the new line meter line meter*/
|
||||||
|
if(copy == NULL) {
|
||||||
|
lv_obj_set_size(new_lmeter, 1 * LV_DPI, 1 * LV_DPI);
|
||||||
|
lv_obj_set_style(new_lmeter, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL));
|
||||||
|
}
|
||||||
|
/*Copy an existing line meter*/
|
||||||
|
else {
|
||||||
|
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||||
|
ext->scale_angle = copy_ext->scale_angle;
|
||||||
|
ext->scale_num = copy_ext->scale_num;
|
||||||
|
|
||||||
|
|
||||||
|
/*Refresh the style with new signal function*/
|
||||||
|
lv_obj_refr_style(new_lmeter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_lmeter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal function of the line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @param sign a signal type from lv_signal_t enum
|
||||||
|
* @param param pointer to a signal specific variable
|
||||||
|
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||||
|
*/
|
||||||
|
bool lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param)
|
||||||
|
{
|
||||||
|
bool valid;
|
||||||
|
|
||||||
|
/* Include the ancient signal function */
|
||||||
|
valid = lv_bar_signal(lmeter, sign, param);
|
||||||
|
|
||||||
|
/* The object can be deleted so check its validity and then
|
||||||
|
* make the object specific signal handling */
|
||||||
|
if(valid != false) {
|
||||||
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=====================
|
||||||
|
* Setter functions
|
||||||
|
*====================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the scale settings of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @param angle angle of the scale (0..360)
|
||||||
|
* @param num number of scale units
|
||||||
|
*/
|
||||||
|
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t num)
|
||||||
|
{
|
||||||
|
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||||
|
ext->scale_angle = angle;
|
||||||
|
ext->scale_num = num;
|
||||||
|
|
||||||
|
lv_obj_inv(lmeter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=====================
|
||||||
|
* Getter functions
|
||||||
|
*====================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scale number of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @return number of the scale units
|
||||||
|
*/
|
||||||
|
uint8_t lv_lmeter_get_scale_num(lv_obj_t * lmeter)
|
||||||
|
{
|
||||||
|
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||||
|
return ext->scale_num ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scale angle of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @return angle of the scale
|
||||||
|
*/
|
||||||
|
uint16_t lv_lmeter_get_scale_angle(lv_obj_t * lmeter)
|
||||||
|
{
|
||||||
|
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||||
|
return ext->scale_angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* STATIC FUNCTIONS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the drawing related tasks of the line meters
|
||||||
|
* @param lmeter 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_lmeter_design(lv_obj_t * lmeter, 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 false;
|
||||||
|
}
|
||||||
|
/*Draw the object*/
|
||||||
|
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||||
|
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||||
|
lv_style_t * style = lv_obj_get_style(lmeter);
|
||||||
|
|
||||||
|
lv_style_t style_tmp;
|
||||||
|
memcpy(&style_tmp, style, sizeof(lv_style_t));
|
||||||
|
|
||||||
|
cord_t r_out = lv_obj_get_width(lmeter) / 2;
|
||||||
|
cord_t r_in =r_out - style->hpad;
|
||||||
|
cord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->cords.x1;
|
||||||
|
cord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->cords.y1;
|
||||||
|
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
||||||
|
int16_t min = lv_bar_get_min_value(lmeter);
|
||||||
|
int16_t max = lv_bar_get_max_value(lmeter);
|
||||||
|
int16_t level = (int32_t)((int32_t)(lv_bar_get_value(lmeter) - min) * ext->scale_num) / (max - min);
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
style_tmp.ccolor = style->mcolor;
|
||||||
|
|
||||||
|
for(i = 0; i < ext->scale_num; i++) {
|
||||||
|
/*Calculate the position a scale label*/
|
||||||
|
int16_t angle = (i * ext->scale_angle) / (ext->scale_num - 1) + angle_ofs;
|
||||||
|
|
||||||
|
cord_t y_out = (int32_t)((int32_t)trigo_sin(angle) * r_out) / TRIGO_SIN_MAX;
|
||||||
|
cord_t x_out = (int32_t)((int32_t)trigo_sin(angle + 90) * r_out) / TRIGO_SIN_MAX;
|
||||||
|
cord_t y_in = (int32_t)((int32_t)trigo_sin(angle) * r_in) / TRIGO_SIN_MAX;
|
||||||
|
cord_t x_in = (int32_t)((int32_t)trigo_sin(angle + 90) * r_in) / TRIGO_SIN_MAX;
|
||||||
|
|
||||||
|
point_t p1;
|
||||||
|
point_t p2;
|
||||||
|
|
||||||
|
p2.x = x_in + x_ofs;
|
||||||
|
p2.y = y_in + y_ofs;
|
||||||
|
|
||||||
|
p1.x = x_out+ x_ofs;
|
||||||
|
p1.y = y_out + y_ofs;
|
||||||
|
|
||||||
|
if(i > level) style_tmp.ccolor = style->ccolor;
|
||||||
|
else {
|
||||||
|
style_tmp.ccolor=color_mix(style->gcolor, style->mcolor, (255 * i) / ext->scale_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_draw_line(&p1, &p2, mask, &style_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/*Post draw when the children are drawn*/
|
||||||
|
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
89
lv_objx/lv_lmeter.h
Normal file
89
lv_objx/lv_lmeter.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* @file lv_lmeter.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*Search an replace: line meter -> object normal name with lower case (e.g. button, label etc.)
|
||||||
|
* lmeter -> object short name with lower case(e.g. btn, label etc)
|
||||||
|
* LMETER -> object short name with upper case (e.g. BTN, LABEL etc.)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LV_LMETER_H
|
||||||
|
#define LV_LMETER_H
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* INCLUDES
|
||||||
|
*********************/
|
||||||
|
#include "lv_conf.h"
|
||||||
|
#if USE_LV_LMETER != 0
|
||||||
|
|
||||||
|
#include "../lv_obj/lv_obj.h"
|
||||||
|
#include "lv_bar.h"
|
||||||
|
|
||||||
|
/*********************
|
||||||
|
* DEFINES
|
||||||
|
*********************/
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* TYPEDEFS
|
||||||
|
**********************/
|
||||||
|
/*Data of line meter*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
||||||
|
/*New data for this type */
|
||||||
|
uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
|
||||||
|
uint8_t scale_num; /*Number of scale units */
|
||||||
|
}lv_lmeter_ext_t;
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* GLOBAL PROTOTYPES
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a line meter objects
|
||||||
|
* @param par pointer to an object, it will be the parent of the new line meter
|
||||||
|
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
|
||||||
|
* @return pointer to the created line meter
|
||||||
|
*/
|
||||||
|
lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal function of the line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @param sign a signal type from lv_signal_t enum
|
||||||
|
* @param param pointer to a signal specific variable
|
||||||
|
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||||
|
*/
|
||||||
|
bool lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the scale settings of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @param angle angle of the scale (0..360)
|
||||||
|
* @param num number of scale units
|
||||||
|
*/
|
||||||
|
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scale number of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @return number of the scale units
|
||||||
|
*/
|
||||||
|
uint8_t lv_lmeter_get_scale_num(lv_obj_t * lmeter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scale angle of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @return angle of the scale
|
||||||
|
*/
|
||||||
|
uint16_t lv_lmeter_get_scale_angle(lv_obj_t * lmeter);
|
||||||
|
/**********************
|
||||||
|
* MACROS
|
||||||
|
**********************/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -29,12 +29,10 @@
|
|||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mode_t mode);
|
static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mode_t mode);
|
||||||
static void lv_templs_init(void);
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
static lv_templs_t lv_templs_def; /*Default template style*/
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
@@ -56,7 +54,7 @@ static lv_templs_t lv_templs_def; /*Default template style*/
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
||||||
{
|
{
|
||||||
/*Create the ancestor template*/
|
/*Create the ancestor of template*/
|
||||||
/*TODO modify it to the ancestor create function */
|
/*TODO modify it to the ancestor create function */
|
||||||
lv_obj_t * new_templ = lv_ANCESTOR_create(par, copy);
|
lv_obj_t * new_templ = lv_ANCESTOR_create(par, copy);
|
||||||
dm_assert(new_templ);
|
dm_assert(new_templ);
|
||||||
@@ -66,7 +64,7 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
|||||||
dm_assert(ext);
|
dm_assert(ext);
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
|
ext->xyz = 0;
|
||||||
|
|
||||||
/*The signal and design functions are not copied so set them here*/
|
/*The signal and design functions are not copied so set them here*/
|
||||||
lv_obj_set_signal_f(new_templ, lv_templ_signal);
|
lv_obj_set_signal_f(new_templ, lv_templ_signal);
|
||||||
@@ -74,7 +72,7 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
|||||||
|
|
||||||
/*Init the new template template*/
|
/*Init the new template template*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
lv_obj_set_style(new_templ, lv_templs_get(LV_TEMPLS_DEF, NULL));
|
lv_obj_set_style(new_templ, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||||
}
|
}
|
||||||
/*Copy an existing template*/
|
/*Copy an existing template*/
|
||||||
else {
|
else {
|
||||||
@@ -105,12 +103,8 @@ bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param)
|
|||||||
/* The object can be deleted so check its validity and then
|
/* The object can be deleted so check its validity and then
|
||||||
* make the object specific signal handling */
|
* make the object specific signal handling */
|
||||||
if(valid != false) {
|
if(valid != false) {
|
||||||
switch(sign) {
|
if(sign == LV_SIGNAL_CLEANUP) {
|
||||||
case LV_SIGNAL_CLEANUP:
|
|
||||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,40 +129,6 @@ 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)
|
|
||||||
{
|
|
||||||
static bool style_inited = false;
|
|
||||||
|
|
||||||
/*Make the style initialization if it is not done yet*/
|
|
||||||
if(style_inited == false) {
|
|
||||||
lv_templs_init();
|
|
||||||
style_inited = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
lv_templs_t *style_p;
|
|
||||||
|
|
||||||
switch(style) {
|
|
||||||
case LV_TEMPLS_DEF:
|
|
||||||
style_p = &lv_templs_def;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
style_p = &lv_templs_def;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(copy != NULL) {
|
|
||||||
if(style_p != NULL) memcpy(copy, style_p, sizeof(lv_templs_t));
|
|
||||||
else memcpy(copy, &lv_templs_def, sizeof(lv_templs_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
return style_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
@@ -203,12 +163,4 @@ 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_templs_init(void)
|
|
||||||
{
|
|
||||||
/*Default style*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,19 +35,6 @@ typedef struct
|
|||||||
/*New data for this type */
|
/*New data for this type */
|
||||||
}lv_templ_ext_t;
|
}lv_templ_ext_t;
|
||||||
|
|
||||||
/*Style of template*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/*Style of ancestor*/
|
|
||||||
/*New style element for this type */
|
|
||||||
}lv_templs_t;
|
|
||||||
|
|
||||||
/*Built-in styles of template*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
LV_TEMPLS_DEF,
|
|
||||||
}lv_templs_builtin_t;
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
@@ -69,13 +56,6 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy);
|
|||||||
*/
|
*/
|
||||||
bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param);
|
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);
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
|
|||||||
Reference in New Issue
Block a user