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 
36 /*Data of color picker*/
37 typedef struct {
38     lv_obj_t obj;
39     lv_color_hsv_t hsv;
40     struct {
41         lv_point_t pos;
42         uint8_t recolor     : 1;
43     } knob;
44     uint32_t last_click_time;
45     uint32_t last_change_time;
46     lv_point_t last_press_point;
47     lv_colorwheel_mode_t mode  : 2;
48     uint8_t mode_fixed            : 1;
49 } lv_colorwheel_t;
50 
51 extern const lv_obj_class_t lv_colorwheel_class;
52 
53 /**********************
54  * GLOBAL PROTOTYPES
55  **********************/
56 
57 /**
58  * Create a color picker object with disc shape
59  * @param parent pointer to an object, it will be the parent of the new color picker
60  * @param knob_recolor true: set the knob's color to the current color
61  * @return pointer to the created color picker
62  */
63 lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor);
64 
65 /*=====================
66  * Setter functions
67  *====================*/
68 
69 /**
70  * Set the current hsv of a color wheel.
71  * @param colorwheel pointer to color wheel object
72  * @param color current selected hsv
73  * @return true if changed, otherwise false
74  */
75 bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv);
76 
77 /**
78  * Set the current color of a color wheel.
79  * @param colorwheel pointer to color wheel object
80  * @param color current selected color
81  * @return true if changed, otherwise false
82  */
83 bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color);
84 
85 /**
86  * Set the current color mode.
87  * @param colorwheel pointer to color wheel object
88  * @param mode color mode (hue/sat/val)
89  */
90 void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode);
91 
92 /**
93  * Set if the color mode is changed on long press on center
94  * @param colorwheel pointer to color wheel object
95  * @param fixed color mode cannot be changed on long press
96  */
97 void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed);
98 
99 /*=====================
100  * Getter functions
101  *====================*/
102 
103 /**
104  * Get the current selected hsv of a color wheel.
105  * @param colorwheel pointer to color wheel object
106  * @return current selected hsv
107  */
108 lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj);
109 
110 /**
111  * Get the current selected color of a color wheel.
112  * @param colorwheel pointer to color wheel object
113  * @return color current selected color
114  */
115 lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj);
116 
117 /**
118  * Get the current color mode.
119  * @param colorwheel pointer to color wheel object
120  * @return color mode (hue/sat/val)
121  */
122 lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj);
123 
124 /**
125  * Get if the color mode is changed on long press on center
126  * @param colorwheel pointer to color wheel object
127  * @return mode cannot be changed on long press
128  */
129 bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj);
130 
131 /**********************
132  *      MACROS
133  **********************/
134 
135 #endif  /*LV_USE_COLORWHEEL*/
136 
137 #ifdef __cplusplus
138 } /*extern "C"*/
139 #endif
140 
141 #endif /*LV_COLORWHEEL_H*/
142 
143