acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_arc.h (6039B)

      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 
     30 enum {
     31     LV_ARC_MODE_NORMAL,
     32     LV_ARC_MODE_SYMMETRICAL,
     33     LV_ARC_MODE_REVERSE
     34 };
     35 typedef uint8_t lv_arc_mode_t;
     36 
     37 typedef struct {
     38     lv_obj_t obj;
     39     uint16_t rotation;
     40     uint16_t indic_angle_start;
     41     uint16_t indic_angle_end;
     42     uint16_t bg_angle_start;
     43     uint16_t bg_angle_end;
     44     int16_t value;              /*Current value of the arc*/
     45     int16_t min_value;          /*Minimum value of the arc*/
     46     int16_t max_value;          /*Maximum value of the arc*/
     47     uint16_t dragging    : 1;
     48     uint16_t type        : 2;
     49     uint16_t min_close   : 1;   /*1: the last pressed angle was closer to minimum end*/
     50     uint16_t chg_rate;          /*Drag angle rate of change of the arc (degrees/sec)*/
     51     uint32_t last_tick;         /*Last dragging event timestamp of the arc*/
     52     int16_t last_angle;         /*Last dragging angle of the arc*/
     53 } lv_arc_t;
     54 
     55 extern const lv_obj_class_t lv_arc_class;
     56 
     57 /**
     58  * `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_arc_class`
     59  * Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
     60  */
     61 typedef enum {
     62     LV_ARC_DRAW_PART_BACKGROUND,    /**< The background arc*/
     63     LV_ARC_DRAW_PART_FOREGROUND,    /**< The foreground arc*/
     64     LV_ARC_DRAW_PART_KNOB,          /**< The knob*/
     65 } lv_arc_draw_part_type_t;
     66 
     67 /**********************
     68  * GLOBAL PROTOTYPES
     69  **********************/
     70 
     71 /**
     72  * Create an arc object
     73  * @param parent pointer to an object, it will be the parent of the new arc
     74  * @return pointer to the created arc
     75  */
     76 lv_obj_t * lv_arc_create(lv_obj_t * parent);
     77 
     78 /*======================
     79  * Add/remove functions
     80  *=====================*/
     81 
     82 /*=====================
     83  * Setter functions
     84  *====================*/
     85 
     86 /**
     87  * Set the start angle of an arc. 0 deg: right, 90 bottom, etc.
     88  * @param arc   pointer to an arc object
     89  * @param start the start angle
     90  */
     91 void lv_arc_set_start_angle(lv_obj_t * arc, uint16_t start);
     92 
     93 /**
     94  * Set the end angle of an arc. 0 deg: right, 90 bottom, etc.
     95  * @param arc   pointer to an arc object
     96  * @param end   the end angle
     97  */
     98 void lv_arc_set_end_angle(lv_obj_t * arc, uint16_t end);
     99 
    100 /**
    101  * Set the start and end angles
    102  * @param arc   pointer to an arc object
    103  * @param start the start angle
    104  * @param end   the end angle
    105  */
    106 void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
    107 
    108 /**
    109  * Set the start angle of an arc background. 0 deg: right, 90 bottom, etc.
    110  * @param arc   pointer to an arc object
    111  * @param start the start angle
    112  */
    113 void lv_arc_set_bg_start_angle(lv_obj_t * arc, uint16_t start);
    114 
    115 /**
    116  * Set the start angle of an arc background. 0 deg: right, 90 bottom etc.
    117  * @param arc   pointer to an arc object
    118  * @param end   the end angle
    119  */
    120 void lv_arc_set_bg_end_angle(lv_obj_t * arc, uint16_t end);
    121 
    122 /**
    123  * Set the start and end angles of the arc background
    124  * @param arc   pointer to an arc object
    125  * @param start the start angle
    126  * @param end   the end angle
    127  */
    128 void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
    129 
    130 /**
    131  * Set the rotation for the whole arc
    132  * @param arc       pointer to an arc object
    133  * @param rotation  rotation angle
    134  */
    135 void lv_arc_set_rotation(lv_obj_t * arc, uint16_t rotation);
    136 
    137 /**
    138  * Set the type of arc.
    139  * @param arc   pointer to arc object
    140  * @param mode  arc's mode
    141  */
    142 void lv_arc_set_mode(lv_obj_t * arc, lv_arc_mode_t type);
    143 
    144 /**
    145  * Set a new value on the arc
    146  * @param arc   pointer to an arc object
    147  * @param value new value
    148  */
    149 void lv_arc_set_value(lv_obj_t * arc, int16_t value);
    150 
    151 /**
    152  * Set minimum and the maximum values of an arc
    153  * @param arc   pointer to the arc object
    154  * @param min   minimum value
    155  * @param max   maximum value
    156  */
    157 void lv_arc_set_range(lv_obj_t * arc, int16_t min, int16_t max);
    158 
    159 /**
    160  * Set a change rate to limit the speed how fast the arc should reach the pressed point.
    161  * @param arc       pointer to an arc object
    162  * @param rate      the change rate
    163  */
    164 void lv_arc_set_change_rate(lv_obj_t * arc, uint16_t rate);
    165 
    166 /*=====================
    167  * Getter functions
    168  *====================*/
    169 
    170 /**
    171  * Get the start angle of an arc.
    172  * @param arc   pointer to an arc object
    173  * @return      the start angle [0..360]
    174  */
    175 uint16_t lv_arc_get_angle_start(lv_obj_t * obj);
    176 
    177 /**
    178  * Get the end angle of an arc.
    179  * @param arc   pointer to an arc object
    180  * @return      the end angle [0..360]
    181  */
    182 uint16_t lv_arc_get_angle_end(lv_obj_t * obj);
    183 
    184 /**
    185  * Get the start angle of an arc background.
    186  * @param arc   pointer to an arc object
    187  * @return the  start angle [0..360]
    188  */
    189 uint16_t lv_arc_get_bg_angle_start(lv_obj_t * obj);
    190 
    191 /**
    192  * Get the end angle of an arc background.
    193  * @param arc   pointer to an arc object
    194  * @return      the end angle [0..360]
    195  */
    196 uint16_t lv_arc_get_bg_angle_end(lv_obj_t * obj);
    197 
    198 /**
    199  * Get the value of an arc
    200  * @param arc       pointer to an arc object
    201  * @return the      value of the arc
    202  */
    203 int16_t lv_arc_get_value(const lv_obj_t * obj);
    204 
    205 /**
    206  * Get the minimum value of an arc
    207  * @param arc   pointer to an arc object
    208  * @return      the minimum value of the arc
    209  */
    210 int16_t lv_arc_get_min_value(const lv_obj_t * obj);
    211 
    212 /**
    213  * Get the maximum value of an arc
    214  * @param arc   pointer to an arc object
    215  * @return      the maximum value of the arc
    216  */
    217 int16_t lv_arc_get_max_value(const lv_obj_t * obj);
    218 
    219 /**
    220  * Get whether the arc is type or not.
    221  * @param arc       pointer to an arc object
    222  * @return          arc's mode
    223  */
    224 lv_arc_mode_t lv_arc_get_mode(const lv_obj_t * obj);
    225 
    226 /*=====================
    227  * Other functions
    228  *====================*/
    229 
    230 /**********************
    231  *      MACROS
    232  **********************/
    233 
    234 #endif /*LV_USE_ARC*/
    235 
    236 #ifdef __cplusplus
    237 } /*extern "C"*/
    238 #endif
    239 
    240 #endif /*LV_ARC_H*/