From dc17c3d462fd597fde03b90909b847df83106677 Mon Sep 17 00:00:00 2001 From: Gabor Date: Tue, 4 Oct 2016 15:29:52 +0200 Subject: [PATCH] code formatting --- lv_objx/lv_btn.c | 38 ++++++++++++++++-------------------- lv_objx/lv_btnm.c | 43 +++++++++++++++++++++-------------------- lv_objx/lv_chart.c | 6 +++--- lv_objx/lv_led.c | 23 +++++++++++----------- lv_objx/lv_objx_templ.c | 17 ++++++++++++++++ lv_objx/lv_page.c | 23 ++++++++++------------ lv_objx/lv_pb.c | 2 +- lv_objx/lv_ta.c | 11 ++++++++++- 8 files changed, 91 insertions(+), 72 deletions(-) diff --git a/lv_objx/lv_btn.c b/lv_objx/lv_btn.c index bb7310f36..e44678c69 100644 --- a/lv_objx/lv_btn.c +++ b/lv_objx/lv_btn.c @@ -25,16 +25,12 @@ * STATIC PROTOTYPES **********************/ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode); -static void lv_btns_init(void); static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p); +static void lv_btns_init(void); /********************** * STATIC VARIABLES **********************/ - -/*----------------- - * Style definition - *-----------------*/ static lv_btns_t lv_btns_def; static lv_btns_t lv_btns_transp; static lv_btns_t lv_btns_border; @@ -365,6 +361,22 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod return true; } +/** + * Load the corresponding style according to the state to 'rects' in 'lv_btns_t' + * @param obj_dp pointer to a button object + */ +static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p) +{ + lv_btn_state_t state = lv_btn_get_state(obj_dp); + lv_btns_t * btns_p = lv_obj_get_style(obj_dp); + + /*Load the style*/ + memcpy(rects_p, &btns_p->rects, sizeof(lv_rects_t)); + rects_p->objs.color = btns_p->mcolor[state]; + rects_p->gcolor = btns_p->gcolor[state]; + rects_p->bcolor = btns_p->bcolor[state]; +} + /** * Initialize the button styles */ @@ -422,20 +434,4 @@ static void lv_btns_init(void) lv_btns_border.rects.vpad = 5 * LV_STYLE_MULT; } -/** - * Load the corresponding style according to the state to 'rects' in 'lv_btns_t' - * @param obj_dp pointer to a button object - */ -static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p) -{ - lv_btn_state_t state = lv_btn_get_state(obj_dp); - lv_btns_t * btns_p = lv_obj_get_style(obj_dp); - - /*Load the style*/ - memcpy(rects_p, &btns_p->rects, sizeof(lv_rects_t)); - rects_p->objs.color = btns_p->mcolor[state]; - rects_p->gcolor = btns_p->gcolor[state]; - rects_p->bcolor = btns_p->bcolor[state]; -} - #endif diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 0948eb384..fe3850e86 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -26,10 +26,10 @@ #if 0 /*Not necessary*/ static bool lv_btnm_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode); #endif -static void lv_btnms_init(void); static uint8_t lv_btnm_get_width_unit(const char * btn_str); static void lv_btnm_create_btns(lv_obj_t * obj_dp, const char ** map_p); static bool lv_btnm_btn_release_action(lv_obj_t * obj_dp, lv_dispi_t * dispi_p); +static void lv_btnms_init(void); /********************** * STATIC VARIABLES @@ -222,6 +222,27 @@ void lv_btnm_set_cb(lv_obj_t * obj_dp, lv_btnm_callback_t cb) * Getter functions *====================*/ +/** + * Get the current map of a button matrix + * @param obj_dp pointer to a button matrix object + * @return the current map + */ +const char ** lv_btnm_get_map(lv_obj_t * obj_dp) +{ + return LV_EA(obj_dp, lv_btnm_ext_t)->map_p; +} + +/** + * Get a the callback function of the buttons on a button matrix + * @param obj_dp: pointer to button matrix object + * @return pointer to the callback function + */ +lv_btnm_callback_t lv_btnm_get_cb(lv_obj_t * obj_dp) +{ + return LV_EA(obj_dp, lv_btnm_ext_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_btnms_builtin_t enum @@ -256,26 +277,6 @@ lv_btnms_t * lv_btnms_get(lv_btnms_builtin_t style, lv_btnms_t * copy_p) return style_p; } -/** - * Get the current map of a button matrix - * @param obj_dp pointer to a button matrix object - * @return the current map - */ -const char ** lv_btnm_get_map(lv_obj_t * obj_dp) -{ - return LV_EA(obj_dp, lv_btnm_ext_t)->map_p; -} - -/** - * Get a the callback function of the buttons on a button matrix - * @param obj_dp: pointer to button matrix object - * @return pointer to the callback function - */ -lv_btnm_callback_t lv_btnm_get_cb(lv_obj_t * obj_dp) -{ - return LV_EA(obj_dp, lv_btnm_ext_t)->cb; -} - /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index 9cb311553..08427eb11 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -9,8 +9,8 @@ #include "lv_conf.h" #if USE_LV_CHART != 0 -#include -#include "lvgl/lv_draw/lv_draw.h" +#include "lv_chart.h" +#include "../lv_draw/lv_draw.h" /********************* * DEFINES @@ -39,8 +39,8 @@ static void lv_chart_draw_cols(lv_obj_t* obj_dp, const area_t * mask_p); /********************** * STATIC VARIABLES **********************/ -static lv_design_f_t ancestor_design_fp; static lv_charts_t lv_charts_def; +static lv_design_f_t ancestor_design_fp; /********************** * MACROS diff --git a/lv_objx/lv_led.c b/lv_objx/lv_led.c index 527326881..aa8f952e0 100644 --- a/lv_objx/lv_led.c +++ b/lv_objx/lv_led.c @@ -171,6 +171,17 @@ void lv_led_tgl(lv_obj_t * obj_dp) * Getter functions *====================*/ +/** + * Get the brightness of a LEd object + * @param obj_dp pointer to LED object + * @return bright 0 (max. dark) ... 255 (max. light) + */ +uint8_t lv_led_get_bright(lv_obj_t * obj_dp) +{ + lv_led_ext_t * ext_dp = lv_obj_get_ext(obj_dp); + return ext_dp->bright; +} + /** * 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 @@ -209,22 +220,10 @@ lv_leds_t * lv_leds_get(lv_leds_builtin_t style, lv_leds_t * copy_p) return style_p; } -/** - * Get the brightness of a LEd object - * @param obj_dp pointer to LED object - * @return bright 0 (max. dark) ... 255 (max. light) - */ -uint8_t lv_led_get_bright(lv_obj_t * obj_dp) -{ - lv_led_ext_t * ext_dp = lv_obj_get_ext(obj_dp); - return ext_dp->bright; -} - /********************** * STATIC FUNCTIONS **********************/ - /** * Handle the drawing related tasks of the leds * @param obj_dp pointer to an object diff --git a/lv_objx/lv_objx_templ.c b/lv_objx/lv_objx_templ.c index 0de7ba6ee..175c9a398 100644 --- a/lv_objx/lv_objx_templ.c +++ b/lv_objx/lv_objx_templ.c @@ -29,6 +29,7 @@ * STATIC PROTOTYPES **********************/ static bool lv_templ_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode); +static void lv_temps_init(void); /********************** * STATIC VARIABLES @@ -127,6 +128,14 @@ bool lv_templ_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param) */ lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy_p) { + static bool style_inited = false; + + /*Make the style initialization if it is not done yet*/ + if(style_inited == false) { + lv_temps_init(); + style_inited = true; + } + lv_templs_t *style_p; switch(style) { @@ -174,4 +183,12 @@ static bool lv_templ_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_m } +/** + * Initialize the template styles + */ +static void lv_temps_init(void) +{ + /*Default style*/ +} + #endif diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index ef5655b07..2c89a0207 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -34,10 +34,9 @@ static void lv_pages_init(void);; /********************** * STATIC VARIABLES **********************/ -static lv_design_f_t ancestor_design_f; - static lv_pages_t lv_pages_def; static lv_pages_t lv_pages_transp; +static lv_design_f_t ancestor_design_f; /********************** * MACROS @@ -273,6 +272,10 @@ static bool lv_scrolling_signal(lv_obj_t* obj_dp, lv_signal_t sign, void* param) return obj_valid; } +/*===================== + * Setter functions + *====================*/ + /** * Glue the object to the page. After it the page can be moved (dragged) with this object too. * @param obj_dp pointer to an object on a page @@ -284,6 +287,11 @@ void lv_page_glue_obj(lv_obj_t* obj_dp, bool en) lv_obj_set_drag(obj_dp, en); } + +/*===================== + * Getter functions + *====================*/ + /** * 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 @@ -321,17 +329,6 @@ lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * to_copy) return style_p; } - - - -/*===================== - * Setter functions - *====================*/ - -/*===================== - * Getter functions - *====================*/ - /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_objx/lv_pb.c b/lv_objx/lv_pb.c index eef0e46e6..bfba40435 100644 --- a/lv_objx/lv_pb.c +++ b/lv_objx/lv_pb.c @@ -34,7 +34,7 @@ static void lv_pbs_init(void); /********************** * STATIC VARIABLES **********************/ -static bool (*ancestor_design_fp)(lv_obj_t*, const area_t *, lv_design_mode_t); +static lv_design_f_t ancestor_design_fp; static lv_pbs_t lv_pbs_def; /********************** diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 5952ba6b4..c0ad7e778 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -438,7 +438,16 @@ static bool lv_ta_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode return true; } - +/** + * An extended label design. Calls the normal label design function and it draws a cursor. + * @param obj_dp pointer to a text area object + * @param mask_p 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_MAIN: draw the object (always return 'true') + * LV_DESIGN_DRAW_POST: drawing after every children are drawn + * @return return true/false, depends on 'mode' + */ static bool lv_ta_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode) { if(mode == LV_DESIGN_COVER_CHK) {