diff --git a/lv_app/lv_app.h b/lv_app/lv_app.h index 0e0e17a74..01b8e3adf 100644 --- a/lv_app/lv_app.h +++ b/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 diff --git a/lv_app/lv_app_util/lv_app_fsel.h b/lv_app/lv_app_util/lv_app_fsel.h index 01af59d27..684afc10b 100644 --- a/lv_app/lv_app_util/lv_app_fsel.h +++ b/lv_app/lv_app_util/lv_app_fsel.h @@ -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 diff --git a/lv_app/lv_app_util/lv_app_kb.c b/lv_app/lv_app_util/lv_app_kb.c index 052b1af80..f2d74d8f2 100644 --- a/lv_app/lv_app_util/lv_app_kb.c +++ b/lv_app/lv_app_util/lv_app_kb.c @@ -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); diff --git a/lv_app/lv_app_util/lv_app_kb.h b/lv_app/lv_app_util/lv_app_kb.h index cd92ed3f7..75afb7f92 100644 --- a/lv_app/lv_app_util/lv_app_kb.h +++ b/lv_app/lv_app_util/lv_app_kb.h @@ -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); /********************** diff --git a/lv_app/lv_app_util/lv_app_notice.h b/lv_app/lv_app_util/lv_app_notice.h index 8ece4189c..2dc25b815 100644 --- a/lv_app/lv_app_util/lv_app_notice.h +++ b/lv_app/lv_app_util/lv_app_notice.h @@ -24,7 +24,17 @@ /********************** * GLOBAL PROTOTYPES **********************/ + +/** + * Initialize the Notifications + */ 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 + */ lv_obj_t * lv_app_notice_add(const char * format, ...); /********************** diff --git a/lv_draw/lv_draw.h b/lv_draw/lv_draw.h index ece7a29fc..a4603cd51 100644 --- a/lv_draw/lv_draw.h +++ b/lv_draw/lv_draw.h @@ -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 **********************/ diff --git a/lv_draw/lv_draw_rbasic.h b/lv_draw/lv_draw_rbasic.h index 3b0cdeee5..bc025db47 100644 --- a/lv_draw/lv_draw_rbasic.h +++ b/lv_draw/lv_draw_rbasic.h @@ -24,14 +24,44 @@ /********************** * 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, bool upscale, - color_t recolor, opa_t recolor_opa); + const color_t * map_p, opa_t opa, bool transp, bool upscale, + color_t recolor, opa_t recolor_opa); + /********************** * MACROS **********************/ diff --git a/lv_draw/lv_draw_vbasic.h b/lv_draw/lv_draw_vbasic.h index 3ab3ff527..f322f3ef0 100644 --- a/lv_draw/lv_draw_vbasic.h +++ b/lv_draw/lv_draw_vbasic.h @@ -28,16 +28,44 @@ /********************** * 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); -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); +/** + * 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); /********************** diff --git a/lv_misc/anim.h b/lv_misc/anim.h index 5c9e7b264..a617b57a7 100644 --- a/lv_misc/anim.h +++ b/lv_misc/anim.h @@ -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 **********************/ diff --git a/lv_misc/area.c b/lv_misc/area.c index 4ebbcbed6..21c398081 100644 --- a/lv_misc/area.c +++ b/lv_misc/area.c @@ -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); @@ -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... */ diff --git a/lv_misc/area.h b/lv_misc/area.h index 4a104fdf3..96514fc6c 100644 --- a/lv_misc/area.h +++ b/lv_misc/area.h @@ -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 diff --git a/lv_misc/circ.h b/lv_misc/circ.h index 1402a576b..3fdcb0025 100644 --- a/lv_misc/circ.h +++ b/lv_misc/circ.h @@ -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); /********************** diff --git a/lv_misc/font.c b/lv_misc/font.c index a119a103e..048567fb3 100644 --- a/lv_misc/font.c +++ b/lv_misc/font.c @@ -107,6 +107,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 **********************/ diff --git a/lv_misc/font.h b/lv_misc/font.h index eec23cbe5..a876fa77c 100644 --- a/lv_misc/font.h +++ b/lv_misc/font.h @@ -64,25 +64,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 @@ -94,24 +91,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 diff --git a/lv_misc/text.c b/lv_misc/text.c index 7fd982943..932d75bdb 100644 --- a/lv_misc/text.c +++ b/lv_misc/text.c @@ -35,6 +35,15 @@ 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) { diff --git a/lv_misc/text.h b/lv_misc/text.h index 097e7ffe8..d3eec2e44 100644 --- a/lv_misc/text.h +++ b/lv_misc/text.h @@ -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 diff --git a/lv_obj/lv_dispi.h b/lv_obj/lv_dispi.h index 540fb6545..51915c264 100644 --- a/lv_obj/lv_dispi.h +++ b/lv_obj/lv_dispi.h @@ -48,13 +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); + +/** + * 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); -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); + +/** + * 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 diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index d6dc1837c..441f79d57 100644 --- a/lv_obj/lv_obj.c +++ b/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; } diff --git a/lv_obj/lv_obj.h b/lv_obj/lv_obj.h index b756d3eeb..5e3bd7fbf 100644 --- a/lv_obj/lv_obj.h +++ b/lv_obj/lv_obj.h @@ -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 diff --git a/lv_obj/lv_refr.h b/lv_obj/lv_refr.h index 9af95225b..423b8a774 100644 --- a/lv_obj/lv_refr.h +++ b/lv_obj/lv_refr.h @@ -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 - **********************/ \ No newline at end of file + **********************/ diff --git a/lv_obj/lv_vdb.h b/lv_obj/lv_vdb.h index 06e1b9574..ea74e98d8 100644 --- a/lv_obj/lv_vdb.h +++ b/lv_obj/lv_vdb.h @@ -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 **********************/ diff --git a/lv_objx/lv_btn.h b/lv_objx/lv_btn.h index eb3e19646..2dae06e79 100644 --- a/lv_objx/lv_btn.h +++ b/lv_objx/lv_btn.h @@ -83,22 +83,87 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_btnm.h b/lv_objx/lv_btnm.h index 8b4d241e3..6d00bf918 100644 --- a/lv_objx/lv_btnm.h +++ b/lv_objx/lv_btnm.h @@ -70,15 +70,65 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_cb.h b/lv_objx/lv_cb.h index d97d9303c..3928abd46 100644 --- a/lv_objx/lv_cb.h +++ b/lv_objx/lv_cb.h @@ -60,10 +60,43 @@ typedef struct /********************** * 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); /********************** diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index e9c3443f6..c42d109cc 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -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 **********************/ diff --git a/lv_objx/lv_chart.h b/lv_objx/lv_chart.h index 54c09ae3b..b45f74ce0 100644 --- a/lv_objx/lv_chart.h +++ b/lv_objx/lv_chart.h @@ -79,23 +79,98 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_gauge.h b/lv_objx/lv_gauge.h index 40ca1de60..9d4136c44 100644 --- a/lv_objx/lv_gauge.h +++ b/lv_objx/lv_gauge.h @@ -3,13 +3,6 @@ * */ - -/*Search an replace: gauge -> object normal name with lower case (e.g. button, label etc.) - * gauge -> object short name with lower case(e.g. btn, label etc) - * GAUGE -> object short name with upper case (e.g. BTN, LABEL etc.) - * - */ - #ifndef LV_GAUGE_H #define LV_GAUGE_H @@ -77,21 +70,100 @@ typedef struct /********************** * GLOBAL PROTOTYPES **********************/ -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); -lv_gauges_t * lv_gauges_get(lv_gauges_builtin_t style, lv_gauges_t * copy); -void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value); + +/** + * 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 **********************/ diff --git a/lv_objx/lv_label.h b/lv_objx/lv_label.h index 0b8ce94b1..ba9655b97 100644 --- a/lv_objx/lv_label.h +++ b/lv_objx/lv_label.h @@ -68,20 +68,92 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_led.h b/lv_objx/lv_led.h index 0ca8e0e82..780956f9e 100644 --- a/lv_objx/lv_led.h +++ b/lv_objx/lv_led.h @@ -53,16 +53,63 @@ typedef struct /********************** * 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); /********************** diff --git a/lv_objx/lv_line.h b/lv_objx/lv_line.h index 67bc3b487..0f817c1ff 100644 --- a/lv_objx/lv_line.h +++ b/lv_objx/lv_line.h @@ -51,17 +51,85 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index f7b3ba2c6..a84f82d0e 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -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; diff --git a/lv_objx/lv_list.h b/lv_objx/lv_list.h index 3dd304048..a3a65109b 100644 --- a/lv_objx/lv_list.h +++ b/lv_objx/lv_list.h @@ -70,15 +70,60 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_mbox.h b/lv_objx/lv_mbox.h index 968714e83..5b67cfe87 100644 --- a/lv_objx/lv_mbox.h +++ b/lv_objx/lv_mbox.h @@ -74,20 +74,91 @@ typedef struct /********************** * GLOBAL PROTOTYPES **********************/ -lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy); -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); +/** + * 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); + +/** + * 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); -bool lv_mbox_close_action (lv_obj_t * mbox, lv_dispi_t *dispi); + +/** + * 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 + */ +bool 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_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); + +/** + * 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_txt(lv_obj_t * mbox, const char * txt); +/** + * 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 diff --git a/lv_objx/lv_objx_templ.h b/lv_objx/lv_objx_templ.h index 49becd1af..7a704fabb 100644 --- a/lv_objx/lv_objx_templ.h +++ b/lv_objx/lv_objx_templ.h @@ -52,8 +52,30 @@ typedef struct /********************** * 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); /********************** diff --git a/lv_objx/lv_page.h b/lv_objx/lv_page.h index e64d76209..bdf738cf8 100644 --- a/lv_objx/lv_page.h +++ b/lv_objx/lv_page.h @@ -74,17 +74,67 @@ typedef struct /********************** * 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 **********************/ diff --git a/lv_objx/lv_pb.h b/lv_objx/lv_pb.h index cf096a233..8c4a04eba 100644 --- a/lv_objx/lv_pb.h +++ b/lv_objx/lv_pb.h @@ -62,13 +62,59 @@ typedef struct /********************** * 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 diff --git a/lv_objx/lv_rect.c b/lv_objx/lv_rect.c index 1fde168bb..8916fa0f3 100644 --- a/lv_objx/lv_rect.c +++ b/lv_objx/lv_rect.c @@ -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) { @@ -670,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); diff --git a/lv_objx/lv_rect.h b/lv_objx/lv_rect.h index 1ebac42bd..cc154dd23 100644 --- a/lv_objx/lv_rect.h +++ b/lv_objx/lv_rect.h @@ -77,16 +77,66 @@ typedef struct /********************** * 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); /********************** diff --git a/lv_objx/lv_ta.h b/lv_objx/lv_ta.h index e656ac37c..f5a1f3535 100644 --- a/lv_objx/lv_ta.h +++ b/lv_objx/lv_ta.h @@ -67,24 +67,105 @@ typedef struct /********************** * 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 diff --git a/lv_objx/lv_win.h b/lv_objx/lv_win.h index 901c37787..362ad8664 100644 --- a/lv_objx/lv_win.h +++ b/lv_objx/lv_win.h @@ -88,16 +88,74 @@ typedef struct /********************** * 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 +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 + * @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 **********************/