1 /** 2 * @file lv_utils.h 3 * 4 */ 5 6 #ifndef LV_UTILS_H 7 #define LV_UTILS_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include <stdint.h> 17 #include <stddef.h> 18 19 /********************* 20 * DEFINES 21 *********************/ 22 23 /********************** 24 * TYPEDEFS 25 **********************/ 26 27 /********************** 28 * GLOBAL PROTOTYPES 29 **********************/ 30 /** 31 * Convert a number to string 32 * @param num a number 33 * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 34 * @return same as `buf` (just for convenience) 35 */ 36 char * lv_utils_num_to_str(int32_t num, char * buf); 37 38 /** Searches base[0] to base[n - 1] for an item that matches *key. 39 * 40 * @note The function cmp must return negative if its first 41 * argument (the search key) is less that its second (a table entry), 42 * zero if equal, and positive if greater. 43 * 44 * @note Items in the array must be in ascending order. 45 * 46 * @param key Pointer to item being searched for 47 * @param base Pointer to first element to search 48 * @param n Number of elements 49 * @param size Size of each element 50 * @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function 51 * example) 52 * 53 * @return a pointer to a matching item, or NULL if none exists. 54 */ 55 void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, 56 int32_t (*cmp)(const void * pRef, const void * pElement)); 57 58 /********************** 59 * MACROS 60 **********************/ 61 62 #ifdef __cplusplus 63 } /* extern "C" */ 64 #endif 65 66 #endif 67