1 /** 2 * @file lv_preload.h 3 * 4 */ 5 6 #ifndef LV_PRELOAD_H 7 #define LV_PRELOAD_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #ifdef LV_CONF_INCLUDE_SIMPLE 17 #include "lv_conf.h" 18 #else 19 #include "../../lv_conf.h" 20 #endif 21 22 #if LV_USE_PRELOAD != 0 23 24 /*Testing of dependencies*/ 25 #if LV_USE_ARC == 0 26 #error "lv_preload: lv_arc is required. Enable it in lv_conf.h (LV_USE_ARC 1) " 27 #endif 28 29 #if LV_USE_ANIMATION == 0 30 #error "lv_preload: animations are required. Enable it in lv_conf.h (LV_USE_ANIMATION 1) " 31 #endif 32 33 #include "../lv_core/lv_obj.h" 34 #include "../lv_misc/lv_anim.h" 35 #include "lv_arc.h" 36 37 /********************* 38 * DEFINES 39 *********************/ 40 41 /********************** 42 * TYPEDEFS 43 **********************/ 44 45 /** 46 * Type of preloader. 47 */ 48 enum { 49 LV_PRELOAD_TYPE_SPINNING_ARC, 50 LV_PRELOAD_TYPE_FILLSPIN_ARC, 51 }; 52 typedef uint8_t lv_preload_type_t; 53 54 /** 55 * Direction the preloader should spin. 56 */ 57 enum { 58 LV_PRELOAD_DIR_FORWARD, 59 LV_PRELOAD_DIR_BACKWARD, 60 }; 61 typedef uint8_t lv_preload_dir_t; 62 63 /*Data of pre loader*/ 64 typedef struct 65 { 66 lv_arc_ext_t arc; /*Ext. of ancestor*/ 67 /*New data for this type */ 68 lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/ 69 uint16_t time; /*Time of one round*/ 70 lv_preload_type_t anim_type : 1; /*Type of the arc animation*/ 71 lv_preload_dir_t anim_dir : 1; /*Animation Direction*/ 72 } lv_preload_ext_t; 73 74 /*Styles*/ 75 enum { 76 LV_PRELOAD_STYLE_MAIN, 77 }; 78 typedef uint8_t lv_preload_style_t; 79 80 /********************** 81 * GLOBAL PROTOTYPES 82 **********************/ 83 84 /** 85 * Create a pre loader objects 86 * @param par pointer to an object, it will be the parent of the new pre loader 87 * @param copy pointer to a pre loader object, if not NULL then the new object will be copied from 88 * it 89 * @return pointer to the created pre loader 90 */ 91 lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy); 92 93 /*====================== 94 * Add/remove functions 95 *=====================*/ 96 97 /** 98 * Set the length of the spinning arc in degrees 99 * @param preload pointer to a preload object 100 * @param deg length of the arc 101 */ 102 void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg); 103 104 /** 105 * Set the spin time of the arc 106 * @param preload pointer to a preload object 107 * @param time time of one round in milliseconds 108 */ 109 void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time); 110 111 /*===================== 112 * Setter functions 113 *====================*/ 114 115 /** 116 * Set a style of a pre loader. 117 * @param preload pointer to pre loader object 118 * @param type which style should be set 119 * @param style pointer to a style 120 * */ 121 void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_style_t * style); 122 123 /** 124 * Set the animation type of a preloader. 125 * @param preload pointer to pre loader object 126 * @param type animation type of the preload 127 * */ 128 void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type); 129 130 /** 131 * Set the animation direction of a preloader 132 * @param preload pointer to pre loader object 133 * @param direction animation direction of the preload 134 */ 135 void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir); 136 137 /*===================== 138 * Getter functions 139 *====================*/ 140 141 /** 142 * Get the arc length [degree] of the a pre loader 143 * @param preload pointer to a pre loader object 144 */ 145 lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload); 146 147 /** 148 * Get the spin time of the arc 149 * @param preload pointer to a pre loader object [milliseconds] 150 */ 151 uint16_t lv_preload_get_spin_time(const lv_obj_t * preload); 152 153 /** 154 * Get style of a pre loader. 155 * @param preload pointer to pre loader object 156 * @param type which style should be get 157 * @return style pointer to the style 158 * */ 159 const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t type); 160 161 /** 162 * Get the animation type of a preloader. 163 * @param preload pointer to pre loader object 164 * @return animation type 165 * */ 166 lv_preload_type_t lv_preload_get_type(lv_obj_t * preload); 167 168 /** 169 * Get the animation direction of a preloader 170 * @param preload pointer to pre loader object 171 * @return animation direction 172 */ 173 lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload); 174 175 /*===================== 176 * Other functions 177 *====================*/ 178 179 /** 180 * Animator function (exec_cb) to rotate the arc of spinner. 181 * @param ptr pointer to preloader 182 * @param val the current desired value [0..360] 183 */ 184 void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val); 185 186 /********************** 187 * MACROS 188 **********************/ 189 190 #endif /*LV_USE_PRELOAD*/ 191 192 #ifdef __cplusplus 193 } /* extern "C" */ 194 #endif 195 196 #endif /*LV_PRELOAD_H*/ 197