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