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 /**   Circular Gauge Management (Circular Gauge)                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_utility.h"
29 #include "gx_system.h"
30 #include "gx_circular_gauge.h"
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_circular_gauge_animation_set                    PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function sets animation steps delay time for a circular gauge. */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    gauge                                 Pointer to circular gauge     */
49 /*                                            control block.              */
50 /*    steps                                 Total steps for one rotation  */
51 /*    delay                                 Delay time for every step     */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_gx_circular_gauge_animation_set(GX_CIRCULAR_GAUGE * gauge,INT steps,INT delay)74 UINT _gx_circular_gauge_animation_set(GX_CIRCULAR_GAUGE *gauge, INT steps, INT delay)
75 {
76 GX_CIRCULAR_GAUGE_INFO *info = &gauge -> gx_circular_gauge_info;
77 
78     info -> gx_circular_gauge_info_animation_steps = steps;
79 
80     if (delay <= 0)
81     {
82         delay = GX_DEFAULT_CIRCULAR_GAUGE_ANIMATION_DELAY;
83     }
84     info -> gx_circular_gauge_info_animation_delay = delay;
85 
86     if (steps > 0)
87     {
88 
89         /* Calculate needle increment angle for each step.  */
90         _gx_circular_gauge_angle_increment_calculate(gauge);
91 
92         /* Start needle animation timer.  */
93         _gx_system_timer_start((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER, (UINT)delay, (UINT)delay);
94     }
95     else
96     {
97         /* Calculate needle increment angle to get from current to target in one step.  */
98         _gx_circular_gauge_angle_increment_calculate(gauge);
99     }
100     return GX_SUCCESS;
101 }
102 
103