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_system.h"
29 #include "gx_widget.h"
30 #include "gx_radial_slider.h"
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_radial_slider_animation_start                   PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This service starts an animation to move the slider needle from     */
45 /*    current postion to the new position.                                */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    slider                                Radial slider control block   */
50 /*    target_angle                          Target angle value            */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _gx_system_timer_start                Start a timer                 */
59 /*    _gx_widget_event_generate             Generate child signal         */
60 /*    _gx_radial_slider_angle_set           Set new slider value          */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Application Code                                                    */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_gx_radial_slider_animation_start(GX_RADIAL_SLIDER * slider,GX_VALUE target_angle)75 UINT _gx_radial_slider_animation_start(GX_RADIAL_SLIDER *slider, GX_VALUE target_angle)
76 {
77 GX_RADIAL_SLIDER_INFO *info = &slider -> gx_radial_slider_info;
78 USHORT                 delay;
79 
80     if (target_angle != info->gx_radial_slider_info_current_angle)
81     {
82         if ((slider -> gx_radial_slider_animation_total_steps > 1) && slider -> gx_radial_slider_animation_delay)
83         {
84             slider -> gx_radial_slider_start_angle = info -> gx_radial_slider_info_current_angle;
85             slider -> gx_radial_slider_target_angle = target_angle;
86             slider -> gx_radial_slider_animation_step = slider -> gx_radial_slider_animation_total_steps;
87             delay = slider -> gx_radial_slider_animation_delay;
88 
89             /* Start animation to move needle from current position to target position. */
90             _gx_system_timer_start((GX_WIDGET *)slider, GX_RADIAL_SLIDER_TIMER, delay, delay);
91 
92             _gx_widget_event_generate((GX_WIDGET *)slider, GX_EVENT_ANIMATION_START, slider -> gx_radial_slider_target_angle);
93         }
94         else
95         {
96             _gx_radial_slider_angle_set(slider, target_angle);
97         }
98     }
99 
100     return(GX_SUCCESS);
101 }
102 
103