1 /** 2 * @file lv_arc.h 3 * 4 */ 5 6 #ifndef LV_ARC_H 7 #define LV_ARC_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../../lv_conf_internal.h" 17 18 #if LV_USE_ARC != 0 19 20 #include "../../core/lv_obj.h" 21 22 /********************* 23 * DEFINES 24 *********************/ 25 26 /********************** 27 * TYPEDEFS 28 **********************/ 29 typedef enum { 30 LV_ARC_MODE_NORMAL, 31 LV_ARC_MODE_SYMMETRICAL, 32 LV_ARC_MODE_REVERSE 33 } lv_arc_mode_t; 34 35 LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_arc_class; 36 37 /********************** 38 * GLOBAL PROTOTYPES 39 **********************/ 40 41 /** 42 * Create an arc object 43 * @param parent pointer to an object, it will be the parent of the new arc 44 * @return pointer to the created arc 45 */ 46 lv_obj_t * lv_arc_create(lv_obj_t * parent); 47 48 /*====================== 49 * Add/remove functions 50 *=====================*/ 51 52 /*===================== 53 * Setter functions 54 *====================*/ 55 56 /** 57 * Set the start angle of an arc. 0 deg: right, 90 bottom, etc. 58 * @param obj pointer to an arc object 59 * @param start the start angle. (if `LV_USE_FLOAT` is enabled it can be fractional too.) 60 */ 61 void lv_arc_set_start_angle(lv_obj_t * obj, lv_value_precise_t start); 62 63 /** 64 * Set the end angle of an arc. 0 deg: right, 90 bottom, etc. 65 * @param obj pointer to an arc object 66 * @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 67 */ 68 void lv_arc_set_end_angle(lv_obj_t * obj, lv_value_precise_t end); 69 70 /** 71 * Set the start and end angles 72 * @param obj pointer to an arc object 73 * @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 74 * @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 75 */ 76 void lv_arc_set_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_precise_t end); 77 78 /** 79 * Set the start angle of an arc background. 0 deg: right, 90 bottom, etc. 80 * @param obj pointer to an arc object 81 * @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 82 */ 83 void lv_arc_set_bg_start_angle(lv_obj_t * obj, lv_value_precise_t start); 84 85 /** 86 * Set the start angle of an arc background. 0 deg: right, 90 bottom etc. 87 * @param obj pointer to an arc object 88 * @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 89 */ 90 void lv_arc_set_bg_end_angle(lv_obj_t * obj, lv_value_precise_t end); 91 92 /** 93 * Set the start and end angles of the arc background 94 * @param obj pointer to an arc object 95 * @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 96 * @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.) 97 */ 98 void lv_arc_set_bg_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_precise_t end); 99 100 /** 101 * Set the rotation for the whole arc 102 * @param obj pointer to an arc object 103 * @param rotation rotation angle 104 */ 105 void lv_arc_set_rotation(lv_obj_t * obj, int32_t rotation); 106 107 /** 108 * Set the type of arc. 109 * @param obj pointer to arc object 110 * @param type arc's mode 111 */ 112 void lv_arc_set_mode(lv_obj_t * obj, lv_arc_mode_t type); 113 114 /** 115 * Set a new value on the arc 116 * @param obj pointer to an arc object 117 * @param value new value 118 */ 119 void lv_arc_set_value(lv_obj_t * obj, int32_t value); 120 121 /** 122 * Set minimum and the maximum values of an arc 123 * @param obj pointer to the arc object 124 * @param min minimum value 125 * @param max maximum value 126 */ 127 void lv_arc_set_range(lv_obj_t * obj, int32_t min, int32_t max); 128 129 /** 130 * Set a change rate to limit the speed how fast the arc should reach the pressed point. 131 * @param obj pointer to an arc object 132 * @param rate the change rate 133 */ 134 void lv_arc_set_change_rate(lv_obj_t * obj, uint32_t rate); 135 136 /** 137 * Set an offset angle for the knob 138 * @param obj pointer to an arc object 139 * @param offset knob offset from main arc in degrees 140 */ 141 void lv_arc_set_knob_offset(lv_obj_t * obj, int32_t offset); 142 143 /*===================== 144 * Getter functions 145 *====================*/ 146 147 /** 148 * Get the start angle of an arc. 149 * @param obj pointer to an arc object 150 * @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) 151 */ 152 lv_value_precise_t lv_arc_get_angle_start(lv_obj_t * obj); 153 154 /** 155 * Get the end angle of an arc. 156 * @param obj pointer to an arc object 157 * @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) 158 */ 159 lv_value_precise_t lv_arc_get_angle_end(lv_obj_t * obj); 160 161 /** 162 * Get the start angle of an arc background. 163 * @param obj pointer to an arc object 164 * @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) 165 */ 166 lv_value_precise_t lv_arc_get_bg_angle_start(lv_obj_t * obj); 167 168 /** 169 * Get the end angle of an arc background. 170 * @param obj pointer to an arc object 171 * @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) 172 */ 173 lv_value_precise_t lv_arc_get_bg_angle_end(lv_obj_t * obj); 174 175 /** 176 * Get the value of an arc 177 * @param obj pointer to an arc object 178 * @return the value of the arc 179 */ 180 int32_t lv_arc_get_value(const lv_obj_t * obj); 181 182 /** 183 * Get the minimum value of an arc 184 * @param obj pointer to an arc object 185 * @return the minimum value of the arc 186 */ 187 int32_t lv_arc_get_min_value(const lv_obj_t * obj); 188 189 /** 190 * Get the maximum value of an arc 191 * @param obj pointer to an arc object 192 * @return the maximum value of the arc 193 */ 194 int32_t lv_arc_get_max_value(const lv_obj_t * obj); 195 196 /** 197 * Get whether the arc is type or not. 198 * @param obj pointer to an arc object 199 * @return arc's mode 200 */ 201 lv_arc_mode_t lv_arc_get_mode(const lv_obj_t * obj); 202 203 /** 204 * Get the rotation for the whole arc 205 * @param obj pointer to an arc object 206 * @return arc's current rotation 207 */ 208 int32_t lv_arc_get_rotation(const lv_obj_t * obj); 209 210 /** 211 * Get the current knob angle offset 212 * @param obj pointer to an arc object 213 * @return arc's current knob offset 214 */ 215 int32_t lv_arc_get_knob_offset(const lv_obj_t * obj); 216 217 /*===================== 218 * Other functions 219 *====================*/ 220 221 /** 222 * Align an object to the current position of the arc (knob) 223 * @param obj pointer to an arc object 224 * @param obj_to_align pointer to an object to align 225 * @param r_offset consider the radius larger with this value (< 0: for smaller radius) 226 */ 227 void lv_arc_align_obj_to_angle(const lv_obj_t * obj, lv_obj_t * obj_to_align, int32_t r_offset); 228 229 /** 230 * Rotate an object to the current position of the arc (knob) 231 * @param obj pointer to an arc object 232 * @param obj_to_rotate pointer to an object to rotate 233 * @param r_offset consider the radius larger with this value (< 0: for smaller radius) 234 */ 235 void lv_arc_rotate_obj_to_angle(const lv_obj_t * obj, lv_obj_t * obj_to_rotate, int32_t r_offset); 236 237 /********************** 238 * MACROS 239 **********************/ 240 241 #endif /*LV_USE_ARC*/ 242 243 #ifdef __cplusplus 244 } /*extern "C"*/ 245 #endif 246 247 #endif /*LV_ARC_H*/ 248