GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_circular_gauge_needle_rotate.c Lines: 17 17 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_widget.h"
29
#include "gx_system.h"
30
#include "gx_circular_gauge.h"
31
#include "gx_utility.h"
32
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_circular_gauge_needle_rotate                    PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function rotates the needle of the specified circular gauge.   */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    circular_gauge                        Circular gauge control block  */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                                Completion status             */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_context_pixelmap_get              Gets the pixelmap associated  */
59
/*                                            the supplied resource ID.   */
60
/*    _gx_utility_pixelmap_rotate           Rotate a pixelmap.            */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/**************************************************************************/
67
1647
UINT  _gx_circular_gauge_needle_rotate(GX_CIRCULAR_GAUGE *gauge)
68
{
69
1647
UINT                    status = GX_SUCCESS;
70
GX_CIRCULAR_GAUGE_INFO *info;
71
INT                    xcor;
72
INT                    ycor;
73
74
75
    /* Pick up pointer to the gauge information structure.  */
76
1647
    info = &gauge -> gx_circular_gauge_info;
77
78
1647
    if (gauge -> gx_circular_gauge_needle_source)
79
    {
80
1646
        xcor = (INT)(info -> gx_circular_gauge_info_needle_xcor);
81
1646
        ycor = (INT)(info -> gx_circular_gauge_info_needle_ycor);
82
83
1646
        gauge -> gx_circular_gauge_current_needle_x = info -> gx_circular_gauge_info_needle_xpos;
84
1646
        gauge -> gx_circular_gauge_current_needle_y = info -> gx_circular_gauge_info_needle_ypos;
85
86
        /* Rotate needle pixelmap. */
87
88
1646
        status = _gx_utility_pixelmap_rotate(gauge -> gx_circular_gauge_needle_source, gauge -> gx_circular_gauge_current_angle,
89
                                                &(gauge -> gx_circular_gauge_needle_rotated),
90
                                                &xcor, &ycor);
91
92
1646
        if (status == GX_SUCCESS)
93
        {
94
            /* Calculate start position of needle pixelmap.  */
95
1644
            gauge -> gx_circular_gauge_current_needle_x = gauge -> gx_widget_size.gx_rectangle_left + info -> gx_circular_gauge_info_needle_xpos;
96
97
1644
            gauge -> gx_circular_gauge_current_needle_x -= xcor;
98
99
1644
            gauge -> gx_circular_gauge_current_needle_y = gauge -> gx_widget_size.gx_rectangle_top + info -> gx_circular_gauge_info_needle_ypos;
100
1644
            gauge -> gx_circular_gauge_current_needle_y -= ycor;
101
        }
102
    }
103
104
1647
    return status;
105
}
106
107
/**************************************************************************/
108
109
UINT  _gx_circular_gauge_needle_rotate_callback(VOID *gauge)
109
{
110
109
    return _gx_circular_gauge_needle_rotate((GX_CIRCULAR_GAUGE *)gauge);
111
}
112