1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Radial Slider Management (Slider)                                   */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_system.h"
30 #include "gx_utility.h"
31 #include "gx_radial_slider.h"
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_radial_slider_animation_update                  PORTABLE C      */
38 /*                                                           6.1.11       */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function updates slider value for each animation step.         */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    slider                                Radial slider control block   */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_utility_easing_function_calculate Calculate next slide angle    */
58 /*                                            with specified easing       */
59 /*                                            function type               */
60 /*    _gx_radial_slider_angle_set           Set radial slider angle       */
61 /*    _gx_system_dirty_mark                 Mark widget as dirty          */
62 /*    _gx_system_timer_stop                 Stop specified timer          */
63 /*    _gx_widget_event_generate             Send event its parent         */
64 /*                                                                        */
65 /*  CALLED BY                                                             */
66 /*                                                                        */
67 /*    GUIX Internal Code                                                  */
68 /*                                                                        */
69 /*  RELEASE HISTORY                                                       */
70 /*                                                                        */
71 /*    DATE              NAME                      DESCRIPTION             */
72 /*                                                                        */
73 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75 /*                                            resulting in version 6.1    */
76 /*  04-25-2022     Ting Zhu                 Modified comment(s),          */
77 /*                                            added animation step test,  */
78 /*                                            resulting in version 6.1.11 */
79 /*                                                                        */
80 /**************************************************************************/
_gx_radial_slider_animation_update(GX_RADIAL_SLIDER * slider)81 UINT _gx_radial_slider_animation_update(GX_RADIAL_SLIDER *slider)
82 {
83 GX_RADIAL_SLIDER_INFO *info = &slider -> gx_radial_slider_info;
84 INT                    current_val = info -> gx_radial_slider_info_current_angle;
85 
86     if (slider -> gx_radial_slider_animation_step > 0)
87     {
88         slider -> gx_radial_slider_animation_step--;
89 
90         _gx_utility_easing_function_calculate(slider -> gx_radial_slider_animation_style,
91                                               slider -> gx_radial_slider_start_angle,
92                                               slider -> gx_radial_slider_target_angle,
93                                               slider -> gx_radial_slider_animation_total_steps - slider -> gx_radial_slider_animation_step,
94                                               slider -> gx_radial_slider_animation_total_steps,
95                                               &current_val);
96 
97         /* set radial slider value. */
98         _gx_radial_slider_angle_set(slider, (GX_VALUE)current_val);
99 
100         if (slider -> gx_radial_slider_animation_update_callback)
101         {
102             /* Call callback function. */
103             slider -> gx_radial_slider_animation_update_callback(slider);
104         }
105 
106         if (slider -> gx_radial_slider_animation_step == 0)
107         {
108             _gx_system_timer_stop((GX_WIDGET *)slider, GX_RADIAL_SLIDER_TIMER);
109 
110             _gx_widget_event_generate((GX_WIDGET *)slider, GX_EVENT_ANIMATION_COMPLETE, current_val);
111         }
112 
113         if (slider -> gx_widget_status & GX_STATUS_VISIBLE)
114         {
115             _gx_system_dirty_mark((GX_WIDGET *)slider);
116         }
117     }
118 
119     return GX_SUCCESS;
120 }
121 
122