GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_circular_gauge_animation_set.c Lines: 11 11 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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
/**************************************************************************/
66
10
UINT _gx_circular_gauge_animation_set(GX_CIRCULAR_GAUGE *gauge, INT steps, INT delay)
67
{
68
10
GX_CIRCULAR_GAUGE_INFO *info = &gauge -> gx_circular_gauge_info;
69
70
10
    info -> gx_circular_gauge_info_animation_steps = steps;
71
72
10
    if (delay <= 0)
73
    {
74
4
        delay = GX_DEFAULT_CIRCULAR_GAUGE_ANIMATION_DELAY;
75
    }
76
10
    info -> gx_circular_gauge_info_animation_delay = delay;
77
78
10
    if (steps > 0)
79
    {
80
81
        /* Calculate needle increment angle for each step.  */
82
1
        _gx_circular_gauge_angle_increment_calculate(gauge);
83
84
        /* Start needle animation timer.  */
85
1
        _gx_system_timer_start((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER, (UINT)delay, (UINT)delay);
86
    }
87
    else
88
    {
89
        /* Calculate needle increment angle to get from current to target in one step.  */
90
9
        _gx_circular_gauge_angle_increment_calculate(gauge);
91
    }
92
10
    return GX_SUCCESS;
93
}
94