1 /**
2  * @file lv_colorwheel.h
3  *
4  */
5 
6 #ifndef LV_COLORWHEEL_H
7 #define LV_COLORWHEEL_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../../lvgl.h"
17 
18 #if LV_USE_COLORWHEEL
19 
20 /*********************
21  *      DEFINES
22  *********************/
23 
24 /**********************
25  *      TYPEDEFS
26  **********************/
27 
28 enum {
29     LV_COLORWHEEL_MODE_HUE,
30     LV_COLORWHEEL_MODE_SATURATION,
31     LV_COLORWHEEL_MODE_VALUE
32 };
33 typedef uint8_t lv_colorwheel_mode_t;
34 
35 /*Data of color picker*/
36 typedef struct {
37     lv_obj_t obj;
38     lv_color_hsv_t hsv;
39     struct {
40         lv_point_t pos;
41         uint8_t recolor     : 1;
42     } knob;
43     uint32_t last_click_time;
44     uint32_t last_change_time;
45     lv_point_t last_press_point;
46     lv_colorwheel_mode_t mode  : 2;
47     uint8_t mode_fixed            : 1;
48 } lv_colorwheel_t;
49 
50 extern const lv_obj_class_t lv_colorwheel_class;
51 
52 /**********************
53  * GLOBAL PROTOTYPES
54  **********************/
55 
56 /**
57  * Create a color picker object with disc shape
58  * @param parent pointer to an object, it will be the parent of the new color picker
59  * @param knob_recolor true: set the knob's color to the current color
60  * @return pointer to the created color picker
61  */
62 lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor);
63 
64 /*=====================
65  * Setter functions
66  *====================*/
67 
68 /**
69  * Set the current hsv of a color wheel.
70  * @param colorwheel pointer to color wheel object
71  * @param color current selected hsv
72  * @return true if changed, otherwise false
73  */
74 bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv);
75 
76 /**
77  * Set the current color of a color wheel.
78  * @param colorwheel pointer to color wheel object
79  * @param color current selected color
80  * @return true if changed, otherwise false
81  */
82 bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color);
83 
84 /**
85  * Set the current color mode.
86  * @param colorwheel pointer to color wheel object
87  * @param mode color mode (hue/sat/val)
88  */
89 void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode);
90 
91 /**
92  * Set if the color mode is changed on long press on center
93  * @param colorwheel pointer to color wheel object
94  * @param fixed color mode cannot be changed on long press
95  */
96 void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed);
97 
98 /*=====================
99  * Getter functions
100  *====================*/
101 
102 /**
103  * Get the current selected hsv of a color wheel.
104  * @param colorwheel pointer to color wheel object
105  * @return current selected hsv
106  */
107 lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj);
108 
109 /**
110  * Get the current selected color of a color wheel.
111  * @param colorwheel pointer to color wheel object
112  * @return color current selected color
113  */
114 lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj);
115 
116 /**
117  * Get the current color mode.
118  * @param colorwheel pointer to color wheel object
119  * @return color mode (hue/sat/val)
120  */
121 lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj);
122 
123 /**
124  * Get if the color mode is changed on long press on center
125  * @param colorwheel pointer to color wheel object
126  * @return mode cannot be changed on long press
127  */
128 bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj);
129 
130 /**********************
131  *      MACROS
132  **********************/
133 
134 #endif  /*LV_USE_COLORWHEEL*/
135 
136 #ifdef __cplusplus
137 } /*extern "C"*/
138 #endif
139 
140 #endif /*LV_COLORWHEEL_H*/
141