GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_circular_gauge_angle_increment_calculate.c Lines: 18 18 100.0 %
Date: 2024-12-05 08:52:37 Branches: 10 10 100.0 %

Line Branch Exec Source
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_circular_gauge.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_circular_gauge_angle_increment_calculate        PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function calcualtes needle angle increments for each step.     */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    circular_gauge                        Circular gauge control block  */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    Application Code                                                    */
61
/*                                                                        */
62
/*  RELEASE HISTORY                                                       */
63
/*                                                                        */
64
/*    DATE              NAME                      DESCRIPTION             */
65
/*                                                                        */
66
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
67
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
68
/*                                            resulting in version 6.1    */
69
/*                                                                        */
70
/**************************************************************************/
71
72
1658
UINT _gx_circular_gauge_angle_increment_calculate(GX_CIRCULAR_GAUGE *gauge)
73
{
74
GX_CIRCULAR_GAUGE_INFO *info;
75
INT                     delay;
76
77
    /* Get gauge info. */
78
1658
    info = &gauge -> gx_circular_gauge_info;
79
80
    /* Calculate total increments.  */
81
1658
    gauge -> gx_circular_gauge_start_angle = gauge -> gx_circular_gauge_current_angle;
82
83
1658
    gauge -> gx_circular_gauge_angle_increment = GX_FIXED_VAL_MAKE(gauge -> gx_circular_gauge_target_angle -
84
                                                  gauge -> gx_circular_gauge_current_angle);
85
1658
    gauge -> gx_circular_gauge_animation_step = 0;
86
87
    /* Devide total increments by total steps.  */
88
1658
    if ((gauge ->gx_widget_status & GX_STATUS_VISIBLE) &&
89
1648
        gauge -> gx_circular_gauge_angle_increment &&
90
1607
        info -> gx_circular_gauge_info_animation_steps > 0)
91
    {
92
27
        gauge -> gx_circular_gauge_angle_increment /= info -> gx_circular_gauge_info_animation_steps;
93
94
        /* Start needle animation timer.  */
95
27
        delay = gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay;
96
97
27
        if (delay <= 0)
98
        {
99
1
            delay = GX_DEFAULT_CIRCULAR_GAUGE_ANIMATION_DELAY;
100
1
            gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay = delay;
101
        }
102
27
        _gx_system_timer_start((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER, (UINT)delay, (UINT)delay);
103
    }
104
    else
105
    {
106
1631
        gauge -> gx_circular_gauge_current_angle = gauge -> gx_circular_gauge_target_angle;
107
108
        /* Mark dirty.  */
109
1631
        if (gauge -> gx_widget_status & GX_STATUS_VISIBLE)
110
        {
111
1621
            _gx_circular_gauge_needle_dirty_mark(gauge);
112
        }
113
    }
114
115
1658
    return GX_SUCCESS;
116
}
117